function Cl(){ this.name=100; this.view=function(){ input=document.createElement('input'); input.name='inputs'; input.addEventListener('click',function(){console.log(this.name)}) document.body.appendChild(input); } } obj=new Cl; obj.view();
Help call console.log (this.name) to get 100; You need to refer to the object created by the constructor. Consider all the options. The more the better. Thanks.