Skip to content

hasGetIndex

hasGetIndex(haystack, needle)

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

返回值:String|Number

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