Skip to content

Instantly share code, notes, and snippets.

@sibnerian
Last active January 23, 2016 21:17
Show Gist options
  • Save sibnerian/ecb726b97ac7c2bf62f6 to your computer and use it in GitHub Desktop.
Save sibnerian/ecb726b97ac7c2bf62f6 to your computer and use it in GitHub Desktop.

Number 1

What does this print (in Node or Chrome)?

console.log([] * 1)

Number 2

What does this print (in Node or Chrome)?

console.log([''] * 1)

Number 3

What does this print (in Node or Chrome)?

console.log(['javascript'] * 1)

Number 4

What does this print (in Node or Chrome)?

function a () {}
var a;
console.log(typeof a);

Number 5

What does this print (in Node or Chrome)?

function a () {}
var a = 4;
console.log(typeof a);

Number 6

What does this print (in Node or Chrome)?

console.log([] + 1 + [])

Number 7

What does this print (in Node or Chrome)?

console.log([] + {})

Number 8

What does this print (in Node or Chrome)?

function a () { return null }
function b () { return new String("javascript") }
function c () { return ['is'] }
function d () { return '!' }

a.prototype.toString = function () { return "funky" } 
b.prototype.toString = function () { return "awesome" } 
c.prototype.toString = function () { return "groovy" } 
d.prototype.toString = function () { return "fun" }

console.log([new a(), new b(),  new c(),  new d()].join(' '))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment