1. Once if A has many instances, adding a new method A.B() to A.prototype will make all instances can use B() right away.
2. A.B() will hide A.prototype.B().
3. All Javascript predefined Objects, prototype is not modifiable.
4. All non-javascript predefined objects, prototype can be defined.
Dom prototype is more a interface.
-
-
Interface objects generally do not have "constructor" functionality (cannot create a new DOM instance by using the JavaScriptnew operator). Exceptions include a few interface objects shipped in previous versions of Internet Explorer:
- Option (alias for HTMLOptionElement)
- Image (alias for HTMLImageElement)
- XMLHttpRequest
- XDomainRequest, which is new to Internet Explorer 8
-
The "prototype" property of interface objects may not be replaced (changed). An interface object's prototype property cannot be assigned a different interface prototype object at run-time.
-
-
Interface prototype objects
-
-
Interface prototype objects define the properties available to all DOM instances, but these built-in properties cannot be permanently replaced (e.g., the JavaScript delete operator will not remove built-in properties).
-
function _MS_HTML5_getElementsByClassName(classList)
{
var tokens = classList.split(" ");
// Pre-fill the list with the results of the first token search.
var staticNodeList = this.querySelectorAll("." + tokens[0]);
// Start the iterator at 1 because the first match is already collected.
for (var i = 1; i < tokens.length; i++)
{
// Search for each token independently
var tempList = this.querySelectorAll("." + tokens[i]);
// Collects the "keepers" between loop iterations
var resultList = new Array();
for (var finalIter = 0; finalIter < staticNodeList.length; finalIter++)
{
var found = false;
for (var tempIter = 0; tempIter < tempList.length; tempIter++)
{
if (staticNodeList[finalIter] == tempList[tempIter])
{
found = true;
break; // Early termination if found
}
}
if (found)
{
// This element was in both lists, it should be perpetuated
// into the next round of token checking...
resultList.push(staticNodeList[finalIter]);
}
}
staticNodeList = resultList; // Copy the AND results for the next token
}
return staticNodeList;
}
HTMLDocument.prototype.getElementsByClassName = _MS_HTML5_getElementsByClassName;
Element.prototype.getElementsByClassName = _MS_HTML5_getElementsByClassName;