先假设运行环境为浏览器
-
10,window,2,Arguments(2)
-
(如果function 是 sum),12undefined
-
undefined 2
-
开头return,以下代码不会执行
-
2,3
-
true true false true
-
5个5,修改为for(let i =1;i<=5;i++)
-
456 和第六题的考点类似,键名都是字符串
-
let arr = [1,2,3,4,5,6] // 这里放需要删除的一个或者多个项 let itemList = [3,4,5] function del(arr,list){ arr.forEach((item,index)=>{ list.forEach((delItem,idx)=>{ if (item ==delItem ){ console.log(item) arr.splice(index) } }) }) } del(arr,itemList) console.log(arr)let arr = [1, 1, 2, 3, 4, 5, 5, 6]; function ES6的写法() { let newrr = [...new Set(arr)]; console.log(newrr); } ES6的写法(); //如果觉得ES6的写法太简单,我提供另外一种写法 let newarray = [] function es5的方法 (){ arr.forEach(function(item,index){ if(newarray.indexOf(item)===-1){ newarray.push(item) }else{ } }) } es5的方法()
11
let obj= {a:1,b:2}
let deepCopyObj = JSON.parse(JSON.stringify(obj));
\