var i = 0 Object.defineProperty(window,'x',{ get(){ return ++i } }) function Fn(){ if(this.constructor == Fn){ this.id =i }else{ let obj = {} obj.__proto__ = Fn.prototype obj.id = i return obj } }