[英]Why the push method doesn't work in this case : [].push
我想在数组声明中直接使用函数push()
,但它无法正常工作。 在我的示例中,我的数组返回值2
:
var j = ["b"].push("a"); document.write(j); // return 2
为什么我的数组返回值2
而不是["b", "a"]
?
push()方法将新项添加到数组的末尾,并返回新的长度。
var j = ["b"].push("a"); console.table(j); // return 2 // this is correct
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.