1const hero = {
2 name: 'Batman'
3};
4
5hero.hasOwnProperty('name'); // => true
6hero.hasOwnProperty('realName'); // => false
1var person = {'first_name': 'bill','age':20};
2
3if ( person.hasOwnProperty('first_name') ) {
4 //person has a first_name property
5}
6
1// the coolest way
2const obj = {
3 weather: 'Sunny;
4}
5
6if('weather' in obj) {
7 // do something
8}
9
10