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.
最近我遇到了一段有趣的 JavaScript 片段。
{} + [] = 0
糟糕,结果为 0。如何添加对象?幕后发生了什么?有人有什么主意吗?
{} 等于 new Object() 并且 [] 等于 new Array() 但这是用于声明。当我添加 {} + [] 时,我得到字符串“[object object]”并且长度等于 15.Aslo 我正在使用 chrome。
如果你使用chrome来执行代码,如果是,V8会在后台动态创建隐藏类v8