hasOwnProperty判断对象是否有这个属性

p = {
    'name': 'maotai',
    'age': 22
};

console.log(p.hasOwnProperty('names'));
p = {
    'name':'maotai',
    'age': 22
};

for(i in p){
    if (p.hasOwnProperty(i)){
        console.log(i);
    }
}

instanceof判断实例是否属于类

arr = [1,2,3];
console.log(arr instanceof Array);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-02-19
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-22
  • 2021-08-13
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2021-09-01
相关资源
相似解决方案