Just return this after the method call

var user = function(name, age) { this.name = name; this.age = age; }; User.prototype.getname = function() {console.log(" name is ",this.name); return this; }; User.prototype. getAge = function() {console.log(" age is ",this.age); return this; }; var user1 = new user("zjf", 22); user1.getName().getAge(); // My name is ZJF // my age is 22Copy the code

Advantages: It is as easy to write as jQuery. Disadvantages: It is not easy to find errors during debugging, that is, it is not conducive to maintenance