Javascript Array count(value)
// Test that a warning will occur when modifying a native object's prototype. Array.prototype.count = function (value) { var count = 0, i; for (i = 0; i < this.length; ++i) { if (this[i] === value) { ++count;//from w w w .j a v a 2 s. c o m } } return count; }; Boolean.prototype = { sup: function () {} }; NonArray.prototype.random = function () { return 4; };
// Test that a warning will occur when modifying a native object's prototype. Array.prototype.count = function (value) { var count = 0, i; for (i = 0; i < this.length; ++i) { if (this[i] === value) { ++count;/*from w ww .j a v a 2s. com*/ } } return count; };