function fun() { var name = 'Anand'; this.get = function() { console.log(name); } } // var get= obj.get var f = new fun(); f.get(); function fun() { var name = 'Anand'; get = function() { console.log(name); } } // var get= obj.get var f = new fun(); f.get();
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter