6
I use new to create objects in javascript and for what I noticed very superficially there is not a big difference between the instance with new and using the prototype.
What’s the difference and what advantage of using the prototype?
6
I use new to create objects in javascript and for what I noticed very superficially there is not a big difference between the instance with new and using the prototype.
What’s the difference and what advantage of using the prototype?
7
Object in Javascript inherits the properties and methods of your Prototype.
This is the Prototype:
function Pessoa(nome, idade) {
this.nome = nome;
this.idade = idade;
}
This is the Object:
var objeto = new Person("Hudson", "26");
console.log(objeto.nome);
Advantage is the same as in Object Oriented, you can read this article here
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.