Chris Sevilleja
@chrisoncode
scotch.io
Sarah Jorgenson
@sarahkapehe
auth0.com/blog
Chris Sevilleja
@chrisoncode
scotch.io
Sarah Jorgenson
@sarahkapehe
auth0.com/blog
'dev ' + 100 + ' mountain'
"dev 100 mountain"
1
let partyLevel = 7;
const newLevel = partyLevel++;
newLevel;
7
let partyLevel = 7;
partyLevel++;
partyLevel;
8
let partyLevel = 7;
partyLevel++;
++partyLevel;
7
9
let partyLevel = '35';
+partyLevel
35
let partyLevel = 'hey im here';
+partyLevel
NaN
typeof hi
typeof null
typeof NaN
typeof /ab+c/
typeof document
undefined
object
number
object
object
typeof Infinity
typeof 'infinity'
typeof (() => 'hello')
typeof [1, 2, 3]
typeof new Array()
number
string
function
object
object
typeof new String()
typeof new Date()
typeof new Number()
typeof new Object()
typeof new Boolean()
!!!object!!!
Â
2
3
console.log(typeof myVariable)
undefined
console.log(myVariable)
Uncaught ReferenceError
sayWhatup();
function sayWhatup() {
alert('whatup')
}
alert
console.log(message);
var message = 'HEY everybody!';
undefined
var message;
console.log(message);
message = 'HEY everybody!';
undefined
sayWhatup();
const sayWhatup = () => {
alert('whatup')
}
Uncaught ReferenceError:
sayWhatup is not defined
var double;
function double(num) {
return (num * 2);
}
console.log(typeof double)
function
function double(num) {
return (num * 2);
}
var double;
console.log(typeof double)
function
function double(num) {
return (num * 2);
}
let double;
console.log(typeof double)
ERROR: Duplicate declaration "double"
4
var name = 'Scotch';
var person = {
name: 'Sarah',
printName() {
console.log(this.name);
}
}
person.printName();
Sarah
var name = 'Scotch';
var person = {
name: 'Sarah',
printName: () => {
console.log(this.name);
}
}
person.printName();
Scotch
const person = {
name: 'Sarah',
printName() {
console.log(this.name);
}
}
const newPrintName = person.printName;
newPrintName();
undefined
const person = {
name: 'Sarah',
printName() {
console.log(this.name);
}
}
const newPrintName = person.printName;
newPrintName.call(person);
Sarah
5
6
var x = 10;
function fistPump() {
x = 20;
}
fistPump();
console.log(x)
20
function doSomethingCool() {
var x = 5;
if (true) {
var x = 10;
console.log(x);
}
console.log(x);
}
doSomethingCool();
10
10
function doSomethingCool() {
let x = 5;
if (true) {
let x = 10;
console.log(x);
}
console.log(x);
}
doSomethingCool();
10
5
7
1 + "1"
'hello' + 'goodbye'
9 + '99' + 100
"11"
"hellogoodbye"
"999100"
12 / "6" === 2
12 - "6" === 6
12 * "6" === 72
12 + "6" === 18
true
true
true
false
["chris", "sarah"] + ["brian", "bella"]
["chris", "sarah"] - ["brian", "bella"]
"chris,sarahbrian,bella"
NaN
new Array(3).toString() === ",,"
',,' == ['', '', '']
',,' === ['', '', '']
true
true
false
[1, 2, 3] == [1, 2, 3]
false
network
network
network
8
Chris Sevilleja
@chrisoncode
scotch.io
Sarah Jorgenson
@sarahkapehe
auth0.com/blog