//----------------------js代码-------------------
var user = {
name:‘tom‘,
say:function(){
console.log("hello");
}
}
//----------------------html页面代码-------------------
<script type="text/javascript" >
user.age = 25;//给user添加属性
user.sayHello = function(){//给user添加方法
console.log("hello other");
}
console.log(user[‘name‘]);
console.log(user[‘age‘]);
console.log(user[‘sayHello‘]);
</script>
js学习(三)-使用大括号({ })语法创建无类型对象
原文地址:https://www.cnblogs.com/kongxc/p/9054795.html