Check if a key exists inside a json object

后端 未结 9 1381
旧巷少年郎
旧巷少年郎 2020-11-29 14:48
amt: \"10.00\"
email: \"sam@gmail.com\"
merchant_id: \"sam\"
mobileNo: \"9874563210\"
orderID: \"123456\"
passkey: \"1234\"

The above is the JSON o

9条回答
  •  死守一世寂寞
    2020-11-29 15:37

    This code causes esLint issue: no-prototype-builtins

    foo.hasOwnProperty("bar") 
    

    The suggest way here is:

    Object.prototype.hasOwnProperty.call(foo, "bar");
    

提交回复
热议问题