JavaScript: Understanding Prototype and Class methods
So, in JavaScript, first of all, its an object oriented programming but without classes (till ES5), now with ES6 we have classes officially in JavaScript But still the old behaviour of the language is forwarded with newer version In Javascript creating an object is possible via its functions( new [Func]()), function is a first class (can be passed as an argument), function is a high order function(can be received as an argument), function it self acts a constructor( new func() ) take a look at below code function User(name, passwd) { this.name = name; this.passwd = passwd; this.methodname = "User" } u1 = new User("User1", "Password") u2 = new User("User2", "Password") console.log(u1) console.log(u2) User.prototype.method1 = function () { console.log("This is method1"); } u1.method1() User.method2 = function() { console.log("this is method2"); } User.me