so if we create two object
var dog = {
var name:"dog",
makeSound: function(){
alert("wow");
}
}
var cate = {
var name:"cate",
makeSound: function(){
alert("meow");
}
}
cate = dog;
now both cate
and dog
point to same object.
and if we do it like this
cate = object.create(dog);
what is the difference between the two is cate
and dog
point to same object now?
object.create
Creates a new object with the specified prototype object and properties.
Not with the same values !
While cate = dog;
just tells cate
to point to the same reference as dog
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.