Published
Edited
Feb 8, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
var bob = {name: "Bob", emotion: "happy", species: "Hooman"}
return bob
}
Insert cell
Insert cell
{
var bob = {
name: 'Mr. Bobz',
caffeinated: true
}
return bob.name
}
Insert cell
Insert cell
function eat() { return "WHERE IS MY NOMS?"}
Insert cell
{
var bob = {name: "Bob", emotion: "Hangry", eat: function() {return "Om nom nom"}}
return eat()
}
Insert cell
{
var bob = {name: "Bob", emotion: "Hangry", eat: function() {return "Om nom nom"}}
return bob.eat()
}
Insert cell
Insert cell
{
var bob = {
name: 'bobz',
hangry: false,
eat: function() {
return hangry;
}
}
return bob.eat()
}
Insert cell
Insert cell
{
var bob = {
name: "Bob",
emotion: "Hangry",
eat: function() {
this.emotion = "Full"
}}
bob.eat()
return bob.emotion
}
Insert cell
Insert cell
thisOutOfContext = function() {
// what could `this` be?
return this;
}
Insert cell
Insert cell
{
var doggo = {
bark: function() {
return this.sound
},
sound: 'wooof!'
}
var doggoII = {
bark: doggo.bark,
sound: 'not wooof!'
}
return doggo.bark()
}
Insert cell
Insert cell
Insert cell
Insert cell
function jerry(){
var jerry =
{
name: 'Jerry',
superpower: 'intelligence',
powerScore: 22,
getPower: function(){
return this.powerScore
},
powerUp: function() {
this.powerScore = this.powerScore + 20
},
setPower: function(score) {
this.powerScore = score
},
favoriteFood: function() {
if(this.powerScore > 50) {
return 'chz'}
else {
return 'mousetrap chz'
}
}
}
return jerry
}
//debug ending here

Insert cell
Insert cell
Insert cell
Insert cell
superCat = function() {
var superCat =
{
name: 'Kitty',
purrStrength: 21,
coatGlossLevel: 25,
runThroughMud: function (){
this.coatGlossLevel = this.coatGlossLevel - 4
this.purrStrength = this.purrStrength - 2
},
changeName: function (newName) {
this.name = newName
},
freeSpaDay: function () {
this.coatGlossLevel = this.coatGlossLevel + 5
this.purrStrength= this.purrStrength + 9
}
}
return superCat;
}
Insert cell
Insert cell
Insert cell
superDoggo = function ()
{
var superDog =
{
name: 'Sparta',
barkstrength: 75,
licktodeath: 110,
loveattack: function() {
this.licktodeath = this.licktodeath + 100
},
deafeningattack: function() {
this.barkstrength = this.barkstrength + 25
},
supername :function (newName){
this.name = newName
}
}
return superDog
}
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