前端判断后端接口是否返回某个字段的时候
<script>var obj = { name: "John", age: 30 };console.log(obj.hasOwnProperty("name")); // 输出 trueconsole.log(obj.hasOwnProperty("email")); // 输出 falselet obj11 = { name: "John", age: 30 };console.log(obj11.name !== undefined); // 输出 trueconsole.log(obj11.email !== undefined); // 输出 false</script>