Test that a warning will occur when modifying a native object's prototype. - Node.js Object

Node.js examples for Object:Object Operation

Description

Test that a warning will occur when modifying a native object's prototype.

Demo Code


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  .ja  v a  2 s  .com*/
    }
  }
  return count;
};

Boolean.prototype = {
  sup: function () {}
};

NonArray.prototype.random = function () {
  return 4;
};

Related Tutorials