What is Basic JavaScript Object Prototype

Publicado el: 05 septiembre 2020
en el canal de: Brnfullstack
23
1

Prototype is all JavaScript objects inherit properties and methods to the class.


Example code :

var Person =function (name,age){
this.name = name;
this.age = age;

}
var objPerson1= new Person("Bikash",30);
var objPerson2= new Person("Bikash1",40);
//inherit properties using prototype
Person.prototype.color="fair";
//inherit method using prototype
Person.prototype.getDetails=function(){
return 'Name : '+this.name +' Age : '+this.age;
}

document.write(objPerson1.getDetails());
console.log(objPerson2.getDetails());

Please subscribe my channel and raise your question in the comment section.


En esta página del sitio puede ver el video en línea What is Basic JavaScript Object Prototype de Duración hora minuto segunda en buena calidad , que subió el usuario Brnfullstack 05 septiembre 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 23 veces y le gustó 1 a los espectadores. Disfruta viendo!