If I want to add the isEmpty method for all JavaScript arrays, I would use the following code
Array.prototype.isEmpty = function() {
return this.length == 0;
}
Suppose this code is in the file foo.js. If I want isEmpty to be available on all pages of a website, would I need to include foo.js in all HTML files? In other words, should prototypes get "reset" when the user goes to another page?
Thanks Don
source
share