Created
          June 29, 2022 02:05 
        
      - 
      
 - 
        
Save szaranger/1985495e357a4a3dbcb6663cec4f77a2 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const person = Object.create(null); | |
| person.age = 21; | |
| if (Object.hasOwn(person, 'age')) { | |
| console.log(person.age); // true - works regardless of how the object was created | |
| } | |
| if (person.hasOwnProperty('age')){ // throws error - person.hasOwnProperty is not a function | |
| console.log('hasOwnProperty: ', person.age); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment