MCPcopy Index your code
hub / github.com/prototypejs/prototype / includes

Function includes

test/unit/static/js/proclaim.js:350–378  ·  view source on GitHub ↗
(haystack, needle)

Source from the content-addressed store, hash-verified

348
349 // Utility for checking whether an object contains another object
350 function includes (haystack, needle) {
351 /* jshint maxdepth: 3*/
352 var i;
353
354 // Array#indexOf, but ie...
355 if (isArray(haystack)) {
356 for (i = haystack.length - 1; i >= 0; i = i - 1) {
357 if (haystack[i] === needle) {
358 return true;
359 }
360 }
361 }
362
363 // String#indexOf
364 if (typeof haystack === 'string') {
365 if (haystack.indexOf(needle) !== -1) {
366 return true;
367 }
368 }
369
370 // Object#hasOwnProperty
371 if (isPlainObject(haystack)) {
372 if (haystack.hasOwnProperty(needle)) {
373 return true;
374 }
375 }
376
377 return false;
378 }
379
380 // Utility for checking whether a value is an array
381 var isArray = Array.isArray || function (val) {

Callers 1

proclaim.jsFile · 0.85

Calls 2

isPlainObjectFunction · 0.85
isArrayFunction · 0.70

Tested by

no test coverage detected