<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script> "use strict" var person = { name:"xiaowang", age:33, score:98 } //定义一个对象; console.log(person.name); delete person.name;//删除对象的属性 console.log(person.name);//undefined person.qq=123123123;//添加对象的属性 console.log(person.qq); console.log("age" in person); //判断属性是否在对象中 console.log("toString" in person); //继承属性是否在对象中; console.log(person.hasOwnProperty('qq')); //判断一个属性是否在这个对象自身拥有,而非继承; </script> </head> <body> </body> </html>
对象类型的详解
最新推荐文章于 2024-08-23 20:55:13 发布