Skip to content

has

has(haystack, needle)

检查是否存在值,存在返回索引/key,不存在返回-1。

返回值:Boolean

参数说明类型可选值默认值
haystack查找范围String | Array | Object
needle要查找的值*
js
console.log(JW.has('banana', 'c'));
console.log(JW.has('', 'a'));