Published
Edited
Feb 11, 2019
2 stars
Insert cell
Insert cell
Insert cell
oneTwoThreeArray = [1,2,3,4,5] //this is how we declare an array
Insert cell
Insert cell
oneTwoThreeArray[0]
Insert cell
oneTwoThreeArray[oneTwoThreeArray.length-1]
Insert cell
Insert cell
Insert cell
Insert cell
emptyArray = [] //this is how we declare an empty array
Insert cell
Insert cell
emptyArray.push(1)
Insert cell
concatArray = emptyArray.concat([4,5,6])
Insert cell
Insert cell
concatArray.pop()
Insert cell
concatArray
Insert cell
Insert cell
Insert cell
myDog = {
// This is how we declare an object!
var myDog = {
name: "fluffy",
breed: "bulldog",
color: "brown"
}
return myDog;
}
Insert cell
// To retrieve values to use them later
myDog.breed
Insert cell
Insert cell
{
var doSomething = function() {
return "I'm doing awesome"
}
var doSomethingTwo = doSomething
// These are equal!
return doSomething === doSomethingTwo
}
Insert cell
Insert cell
myDog2 = {
var myDog2 = {
name: "fluffy",
breed: "bulldog",
color: "brown",
bark: function() {
return "WOOF"
}
}
// just for observable~
return myDog2
}
Insert cell
// run it like this
myDog2.bark()
Insert cell
Insert cell
myDog3 = {
var myDog3 = {
sayName: function() {
return "Hai my name is " + this.name + ". I'm a " + this.breed + "."
},
name: "fluffykins",
breed: "bulldog",
}
return myDog3
}
Insert cell
myDog3.sayName()
Insert cell
Insert cell
thisOutOfContext = function() {
// what could `this` be?
return this;
}
Insert cell
Insert cell
justBark = {
var doggo = {
bark: function() {
return this.sound
},
sound: "wooooof"
}
var justBark = doggo.bark;
return justBark
}
Insert cell
// `this` is no longer the doggo
justBark()
Insert cell
boundBark = {
var doggo = {
bark: function() {
return this.sound
},
sound: "wooooof"
}

var boundBark = doggo.bark;

return boundBark.bind(doggo)
}
Insert cell
// `this` is doggo again
boundBark()
Insert cell
Insert cell
Insert cell
Insert cell
superCat =
{
//write code here
}
Insert cell
Insert cell
superDoggo =
{
}
Insert cell
Insert cell
theirArmy = ["dog1","dog2","dog3","dog4"]
Insert cell
ourArmy = ["superKitty"]
Insert cell
Insert cell
allAnimals = ourArmy + superKitty
Insert cell
allAnimals.addDoggo(superDoggo)
Insert cell
allAnimals.findIndexOfSupperKitty()
Insert cell
allAnimals.removeThatSuperDoggoCuzITypoedHisNameO()
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