js练习题:对象字面量的形式创建一个名字为可可的狗对象
名称:可可 类型:阿拉斯加犬 年龄:5岁 颜色:棕红色 技能:汪汪汪(Call),演电影(ShowFilm)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var obj = {
name:'可可',
type:'阿拉斯加犬',
age:'5岁',
color:'棕红色',
sayCall:function(){
console.log('汪汪汪');
},
getShowFilm: function(){
console.log('演电影');
}
}
console.log(obj.name);
console.log(obj.type);
console.log(obj.age);
console.log(obj.color);
obj.sayCall();
obj.getShowFilm();
</script>
</body>
</html>
|