Published
Edited
Feb 25, 2019
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
{
var globalBob = "bob"
function innerBob()
{
var sinnerBob = globalBob
return sinnerBob;
}
innerBob()
globalBob
return sinnerBob
}
Insert cell
Insert cell
Insert cell
{
function atomBombCode(activate)
{
if(activate===true)
return null
function theft()
{
var laptop = {
secret: "encryptedSecretsHere",
password: function(pass) {if(pass==="Fluffykins21") return "un" + secret}
}
errorBob = bob
sovietThief = laptop
return sovietThief
}
var americanSpy = sovietThief
var happyTheClown = laptop
return [laptop,theft(),americanSpy, sovietThief]
}
var thatBritishDude = americanSpy
var bobbyNugs = atomBombCode(true)[1]
var monsieurSam = atomBombCode(false)[0]
var ivanTheTerrible = theft()
var falsyFakeFriend = atomBombCode(false)[1]
var theAmerican = atomBombCode(true)[2]
var theMartian = atombombCode(false)[4]
var uSSR = falsyFakeFriend
var whatsTheSecret = undefined //say which var contains it here
return whatsTheSecret
}
Insert cell
Insert cell
Insert cell
function Poodle(name, owner) {
var breed = "poodle" //this is private
var sound = "Woof" //this is private
function introduce() {
return "I'm a " + breed + " named " + name +
". My owner is " + owner + "."
}
function setSound(s) {
sound = s
}

return {
talk: function() {
return sound + "! " + introduce()
},
setSound: setSound
}
}
Insert cell
{
var alfred = Poodle("Alfred", "George")
var sput = Poodle("Sput", "Jack")
var lola = Poodle("Lola", "Matt")
return alfred.talk() + "\n" +
sput.talk() + "\n" +
lola.talk() + "\n"
}
Insert cell
Insert cell
Insert cell
function factoryFactory(product, numberofFactories){
return [undefined, undefined, undefined, undefined]
}
Insert cell
Insert cell
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