+ 2
Help me understand the workings of methods in JS
I carry out the task in which it is specified to create an object and within it 2 methods. In each method, output a string. All need to do is to execute this code: obj.method1().method2()
1 Réponse
+ 12
function clas() {
this.method1 = function() {
console.log("method1");
return this;
};
this.method2 = function() {
console.log("method2");
return this;
};
} //clas
var obj = new clas();
obj.method1().method2();