对象的函数解构
直接把这个JSON格式数据当作参数,传递到函数内部进行处理
let json = { a:'jie', b:'杰' } function fun({a,b}){ console.log(a,b); } fun(json) //jie 杰
数组的函数解构
let arr =['jie','biao','nine']; function fun(a,b,c){ console.log(a,b,c) } fun(...arr) //jie biao nine
in
in是用来判断对象或者数组中是否存在某个值的
对象
let obj={ a:'jie' } console.log('a' in obj) // true console.log('b' in obj) //false
数组
这里的0指的是数组下标位置是否为空。
let arr = [,,,]; console.log(0 in arr); //false let arr2 = ['jie','bioa']; console.log(0 in arr2) //true console.log('jie' in arr2) //false
map
var arr2 = ['jie', 'bioa', 'nine']; console.log(arr2.map(item => { return item = "web" })) (3) ["web", "web", "web"] console.log(arr2.map(val => "web")) //(3) ["web", "web", "web"]
数组转为字符串
join
var arr2 = ['jie', 'bioa', 'nine']; console.log(arr2.join('|')) //jie|bioa|nine
toString
var arr2 = ['jie', 'bioa', 'nine']; console.log(arr2.toString()) //jie,bioa,nine