Published
Edited
Feb 26, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//notice that Dog only really defines the introduce attribute
dog = {
var dog = {
introduce: function() {
return 'Hai, I am a Dog!';
}
};
Object.setPrototypeOf(dog, animal);
return dog;
}
Insert cell
Insert cell
dog.makesSound
Insert cell
dog.mustEat
Insert cell
Insert cell
dog.introduce()
Insert cell
dog.introduce()===animal.introduce()
Insert cell
Insert cell
Insert cell
cat = {
var cat = {
tummyRub: function(){
this.mood = 'happy';
},
introduce: function(){
return 'Hai, I am a cat!';
},
meow: true,
purr: true,
mood: "happy"
};
Object.setPrototypeOf(cat, animal);
return cat;
}
Insert cell
Insert cell
Insert cell
Insert cell
accountantKitty = {
var accountantKitty = {
name: "yaya",
introduce: function() {
return "Hai, my name is" + this.name + "a cat!"
},
mustEat: false,
addTwoNumbers: function(x, y) {
return x + y
},
attachKittyToAnArray: function(inputArray) {
var input = inputArray.concat(["kitty"]);
return input
}
}
Object.setPrototypeOf(accountantKitty, cat);
return accountantKitty;
}
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more