Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 828 Bytes

File metadata and controls

27 lines (17 loc) · 828 Bytes

15、下面的代码块会输出什么?为什么?

var arr1 = "john".split('');
var arr2 = arr1.reverse();
var arr3 = "jones".split('');
arr2.push(arr3);
console.log("array 1: length=" + arr1.length + " last=" + arr1.slice(-1));
console.log("array 2: length=" + arr2.length + " last=" + arr2.slice(-1));

结果:

array 1: length=5 last=j,o,n,e,s

array 2: length=5 last=j,o,n,e,s

参考资料:

题目来源

MDN: split

MDN: slice

MDN: reverse