0
let obj = {
  a: 1,
};


if (obj.a === 1 && obj.a === 2 && obj.a === 3) {
  console.log('work');
}

I tried to use defineProperty but It seems bad solution.

let obj ={} 
let i = 1  
Object.defineProperty(obj, 'a', {  
  get: function () {  
  return i++;  
 }  
});  

if(obj.a === 1 && obj.a === 2 && obj.a === 3) {  
console.log('work')  
}

I found solution without strict equality but it isn't fit

It's my first question in this community...

0 Answers0