-9
A
回答
7
.push()
返回数组的新长度。
['one'].push('two'); // returns 2 (array length is 2)
['one', 'two'].push('something'); // returns 3 (array length is 3)
在你的情况:
[].push([]); // array length is 1 where you get array within array. [[]]
相关问题
- 1. 为什么IndexOf返回-1?
- 2. 为什么ISNUMERIC('。')返回1?
- 3. 为什么UINT_MAX返回-1?
- 4. 为什么sqlitedatabase.insert返回-1?
- 5. 为什么retainCount返回-1
- 6. 为什么GetCurrentProcess返回-1?
- 7. 为什么HttpURLConnection.getResponseCode()返回1?
- 8. SDL_BlitSurface()返回-1 ...为什么?
- 9. 为什么(true && 1)返回1,但(1 && true)返回true?
- 10. 为什么getdate返回1 \ 1 \ 1900
- 11. 为什么1!= 1返回true?
- 12. SimpleDateFormat返回1小时为什么?
- 13. 为什么方法返回-1?
- 14. 为什么Boost :: multiprecision :: sqrt(1)返回0?
- 15. 为什么1 && 2返回2?
- 16. 为什么getppid()从孩子返回1
- 17. 为什么HttpWebResponse.ContentLength突然返回-1?
- 18. 为什么FindFirstFileW总是返回-1?
- 19. 为什么getPointerCount()总是返回1?
- 20. 为什么count(false)返回1?
- 21. 为什么这只返回1行?
- 22. 这段代码为什么返回-1?
- 23. Xpath - 为什么只返回1个值?
- 24. BASH:为什么`printf`返回1?
- 25. 为什么preg_match不返回1?
- 26. 为什么返回-1而不是0?
- 27. 为什么chdir(“〜/ dev /”)返回-1?
- 28. 为什么在JavaScript中返回-1
- 29. 为什么filter_var(真,FILTER_VALIDATE_INT)返回1
- 30. 为什么[NSObject respondsToSelector:@selector(init)]返回1?
因为'.push()'返回阵列的新长度。你可以尝试'[] .push([],[],[])'以确保 – Evgeniy 2014-08-28 12:07:35
更好的问题是“push方法返回什么”。答案是“代表新长度的整数”。 – 2014-08-28 12:08:40
阅读[引用优先](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push),然后询问。特别是如果你真的好奇。 – Fedor 2014-08-28 12:09:04