Discuss / JavaScript / Answer

Answer

Topic source

NotFatCat

#1 Created at ... [Delete] [Delete and Lock User]
var obj = {
    birth:1990,
    getAge:function(){

        var b =this.birth;
        var fn = ()=>{
            if(this===window){
               window.open();
            }
            else{
               alert(JSON.stringify(this));   
        } 
        return new Date().getFullYear()-b;
        }
        return fn();  
    }
}

  • 1

Reply