Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
刚刚在下划线的来源中看到了这一点:
if (obj.length === +obj.length) { ... }
做什么的plus?我以前从未见过这个。
plus
它在开发人员中被认为是一种好的做法吗?
加号将字符串转换为浮点数。您提供的代码等效于以下内容:
if ( obj.length === Number(obj.length) ) { // ... }