使用JSON 来定义一个对象:
<script type="text/javascript">
var xiaoming = {
name : ‘xiaoming‘,
age : 18,
say : function(){
console.log(‘my name is ‘+this.name);
}
}
xiaoming.say();
xiaoming.name = ‘li xiao ming‘;
xiaoming.say();
</script>
时间: 2024-10-06 08:59:23