what is prototyping in javascript
what is prototyping in javascript....
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gowtham RajamanickamPosted Apr 16, 2015, 2:48 AM
Munesh SharmaPosted Apr 16, 2015, 2:42 AM
Manoj BhoirPosted Apr 16, 2015, 1:14 AM
The prototype property allows you to add properties and methods to an object.
Syntax
object.prototype.name=value
Example
In this example we will show how to use the prototype property to add a property to an object:
The output of the code above will be:
20000
Reference : http://www.w3schools.com/jsref/jsref_prototype_math.asp
For more details see : http://www.w3schools.com/js/js_object_prototypes.asp
http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/
Joginder BangerPosted Mar 31, 2015, 3:53 PM
All JavaScript objects inherit the properties and methods from their prototype.
Objects created using an object literal, or with new Object(), inherit from a prototype called Object.prototype.
Objects created with new Date() inherit the Date.prototype.
The Object.prototype is on the top of the prototype chain.
All JavaScript objects (Date, Array, RegExp, Function, ....) inherit from the Object.prototype.
one simple Example about the javascript Prototype.
function person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
var myFather = new person("John", "Doe", 50, "blue");
var myMother = new person("Sally", "Rally", 48, "green");
document.getElementById("demo").innerHTML =
"My father is " + myFather.age + ". My mother is " + myMother.age;
output: My Father is 50. My mother is 48.
Referenced by :
www.w3schools.com/js/js_object_prototypes.asp