<script>
//方式一
let obj1 = new Object();
obj1.name = "zs";
obj1.age = 18;
obj1.gender = "male";
obj1.say = function() {
console.log(this.name + ": Hello!");
};
obj1.say();
//方式二
let obj2 = {};
obj2.name = "ls";
obj2.age = 19;
obj2.gender = "male";
obj2.say = function () {
console.log(this.name + ": Hello!");
};
obj2.say();
//方式三
let obj3 = {
name: "ww",
age: 20,
gender: "male",
say : function () {
console.log(this.name + ": Hello!");
}
};
obj3.say();
</script>

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/135970.html
標籤:JavaScript
上一篇:vue-父組件傳遞引數到子組件
