Array.prototype.contains()

Description:

Return a boolean value indicating whether the array has contained the specified item.

Parameters:

  • criteriaObject

Returned Value:

  • A boolean value indicating whether the array has contained the specified item.

Sample:

var array = [{name: "Apple", weight: 200}, {name: "banana", weight: 50}, {name: "berry", weight: 50}, {name: "Lemon", weight: 180}];
var findResult = array.contains({ weight: 50 });
//Result: findResult1 = true;

var array2 = [1,3,5,7,9,12,15];
var findResult2 = array2.contains(9);
//Result: findResult2 = true;

Last edited Feb 5, 2013 at 9:18 AM by rynnwang, version 2

Comments

No comments yet.