Chris on Code
@chrisoncode
scotch.io - digitalocean.com
let partyLevel = 7;
const newLevel = partyLevel++;
newLevel;7
let partyLevel = 7;
partyLevel++;
partyLevel;8
let partyLevel = 7;
partyLevel++;
++partyLevel;7
8
let partyLevel = '35';
+partyLevel35
let partyLevel = 'hey im here';
+partyLevelNaN
typeof hi
typeof null
typeof NaN
typeof /ab+c/
typeof documentundefined
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!!!
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"
var name = 'Scotch';
var person = {
name: 'Chris',
printName() {
console.log(this.name);
}
}
person.printName();Chris
var name = 'Scotch';
var person = {
name: 'Chris on Code',
printName: () => {
console.log(this.name);
}
}
person.printName();Scotch
const person = {
name: 'Chris',
printName() {
console.log(this.name);
}
}
const newPrintName = person.printName;
newPrintName();undefined
const person = {
name: 'Chris on Code',
printName() {
console.log(this.name);
}
}
const newPrintName = person.printName;
newPrintName.call(person);Chris on Code
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
1 + "1"
'hello' + 'goodbye'
9 + '99' + 100"11"
"hellogoodbye"
"999100"
12 / "6" === 2
12 - "6" === 6
12 * "6" === 72
12 + "6" === 18true
true
true
false
["chris", "kapehe"] + ["mo", "bella"]
["chris", "kapehe"] - ["mo", "bella"]
"chris,kapehemo,bella"
NaN
new Array(3).toString() === ",,"
',,' == ['', '', '']
',,' === ['', '', '']true
true
false
[1, 2, 3] == [1, 2, 3]false
Chris on Code
@chrisoncode
scotch.io - Digitalocean.com