通过使用 PHPStorm 的检查代码工具,我得到以下消息:
'recipient_user.id === app.currentUser.id ? true : false'
can be simplified to
'!!(recipient_user.id === app.currentUser.id)'
我的问题是:由于 jslint 提示使用 !!
,是否建议根据 PHPStorm 更改代码?还是可以用更好的方式重写?
最佳答案
我会把它改成:
recipient_user.id === app.currentUser.id
因为这保证返回真正的 bool 值(真或假)。无需使用 !!
强制返回 ===
运算符的值。
关于javascript - javascript 中的概要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11955237/