javascript - Eslint(没有未使用的表达式)
问题描述
我正在使用三元表达式来更改玩家,并且效果很好。ESLint 给了我这个错误 - https://eslint.org/docs/rules/no-unused-expressions
activePlayer === 0 ? (activePlayer = 1) : (activePlayer = 0);
你能帮我把我的代码做得更好吗?
解决方案
activePlayer = activePlayer === 0 ? 1 : 0 ;
推荐阅读
- python - 如果下面的行重复,则使用其他列中的值,直到找到新值
- node.js - MongoDB在日期在表行的开始日期和结束日期之间时获取数据
- snowflake-cloud-data-platform - 如何在雪花中创建一个表,但防止在同一角色下删除它?
- python - 在类的加载方法中覆盖self
- c# - 使用泛型接口子类型解析类型
- javascript - 拿
作为整数
- python - 如果涉及 Inf,为什么稀疏矩阵的矩阵乘法与密集矩阵的乘法不同?
- java - spring-boot java中没有ssl客户端会话缓存
- jmeter - 在 JMeter 中使用 JSR223 后处理器检索请求数据信息
- javascript - 如何使用同步函数在节点 js 中获取目录的大小