yisainan / web-interview

我是齐丶先丶森,收集整理全网面试题及面试技巧,旨在帮助前端工程师们找到一份好工作!更多详见公众号「前端面试秘籍」
MIT License
2.62k stars 505 forks source link

[选择题] 40.(单选题)下面代码的输出是什么 #1018

Open qiilee opened 4 years ago

qiilee commented 4 years ago
let newList = [1, 2, 3].push(4);

console.log(newList.push(5));
A:[1,2,3,4,5]
B: [1,2,3,5]
C: [1,2,3,4]
D: Error

答案:D

解析:

.push()方法返回数组的长度,而不是数组的本身。