Dec
25
2015
By abernal
An object's parent is called : Prototype
The Object prototype
Has the next property functions
- valueOf
- constructor
- toLocaleString
- toString
- isPrototypeOf
- propertyIsEnumerable
- hasOwnProperty
The Array prototype
Has the next property functions
- pop()
- push()
- shift()
- reverse()
- sort()
- join()
- reduce()
- slice()
The String prototype
Has the next property functions
- charAt()
- trim()
- concat()
- indexOf()
- replace()
- toUpperCase()
- toLowerCase()
- substring()
The number prototype
Has the next property functions
- toFixed()
- toExponential()
- toPrecision()
The function prototype
Has the next property functions
- bind()
- call()
- apply()
All of the objects inherit from the Object Prototype
Adding a function to the String Prototype
var witch = "I will get my phone back!" // Adding a function to the String prototype String.prototype.countAll = function( letter ) { var letterCount = 0; for ( var i = 0; i < this.length ; i++ ){ if ( this.chartAt[i].toUpperCase() == letter.toUpperCase() ){ letterCount++; } } return letterCount; }; witch.countAll("I"); // This will return 2, since there are 2 i´s in the witch variable.