8 Things

Nerds Need to Know

Chris Sevilleja

@chrisoncode

scotch.io

Sarah Jorgenson

@sarahkapehe

auth0.com/blog

Who are we?

Chris Sevilleja

@chrisoncode

scotch.io

Sarah Jorgenson

@sarahkapehe

auth0.com/blog

🙌 Show of hands 🙌

What are we doing?

Keys to success

Code stuffs to know




'dev ' + 100 + ' mountain'

"dev 100 mountain"

Unary Operators

1

  • + 👉 Convert to a number
  • ++ 👉 Increment
  • -- 👉 Decrement
  • ! 👉 Logical not
  • !! 👉 Convert to a boolean
  • typeof 👉 Check the type
  • ~ 👉 Inverts all bits. Returns number
  • delete 👉 Remove from array
  • void 👉 Discards a return value

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!!!

Dont

Make

Me

Think

 

2

Hoisting

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"

this

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

be

patient

5

scope

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

Coercion

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

network

8

k. thx. bai.

Chris Sevilleja

@chrisoncode

scotch.io

Sarah Jorgenson

@sarahkapehe

auth0.com/blog

Q&A

8 Things Nerds Need to Know

By Chris Sevilleja

8 Things Nerds Need to Know

  • 3,356