0

How to create prototype in JavaScript

im not understood what exactly for prototype is used

26th Jul 2017, 7:50 PM
Mirza Ahmed Baig
Mirza Ahmed Baig - avatar
2 Respostas
+ 2
Prototype is related to the object oriented aspect of Javascript. To keep it simple, every object in Javascript has a prototype (eg: Date) The prototype is a kind of a blueprint for the object. The following code create an object and then use its prototype to add a method: function myClass(){ myClass.prototype.myMethod = function(){ console.log('hello world') } }
26th Jul 2017, 9:23 PM
Drax
Drax - avatar
0
thanks
27th Jul 2017, 12:51 AM
Mirza Ahmed Baig
Mirza Ahmed Baig - avatar