// return this 가 없는 경우 function a(){ this.name = 'mohwa1'; } a.prototype.getName = function(){ return this.name; } a.prototype.setName = function(name){ this.name = name; } try{ console.log(new a()); console.log(new a().setName('mohwa1-1').getName); } catch(e){ console.log(e.message); } // return this를 해주는 경우 function b(){ this.name = 'mohwa2'; return this; } b.prototype.getName = function(){ return this.name; } b.prototype.setName = function(name){ this.name = name; return this; } try{ console.log(new b()); console.log(new b().setName('mohwa2-1').getName); } catch(e){ console.log(e.message); }