數(shù)組去重
var j = [...new Set([1,2,2,4])];? ? ?// [1,2,4]
判斷對象和數(shù)組方法
Object.prototype.toString.call({}) 返回字符串的 '[object Object]'
Object.prototype.toString.call([]) 返回字符串的 '[object Array]'
對象是否包含某個屬性
Obj.hasOwnProperty('name')
過濾空值
let res = [1,2,0,undefined,null,false,''].filter(Boolean);? ?>>1,2
合并對象
const person = { a:1 };
const tools = { b: 2 };
const attributes = { c:3 };
const summary = {...person, ...tools, ...attributes};? ?>> {a:1, b:2, c:3}