您现在的位置是:网站首页> HTML&JS

JS之判断json对象中是否含有某个key值

  • HTML&JS
  • 2022-12-09
  • 728人已阅读
摘要

var json = {"key1":"val1","key2":"val2","key3":"val3"};

if(json.hasOwnProperty("key1")){

console.log(json["key1]);

}


Top