Skip to content

hasKey

hasKey(haystack, needle)

将对象转化为数组。

返回值:Array

参数说明类型可选值默认值
haystack待检查对象Object
needle待查找的keyString|Number|Boolean
js
console.log(JW.hasKey({a: 1, b: 2}, 'd')); // false
console.log(JW.hasKey({a: 1, b: 2, 1: 2}, 1)); // true
console.log(JW.hasKey({a: 1, b: 2, true: 1}, true)); // true