Skip to content

Instantly share code, notes, and snippets.

@rodrigonehring
Last active February 6, 2018 17:53
Show Gist options
  • Save rodrigonehring/9b6dcbadb77be0a11ac8d6b2de53ef41 to your computer and use it in GitHub Desktop.
Save rodrigonehring/9b6dcbadb77be0a11ac8d6b2de53ef41 to your computer and use it in GitHub Desktop.
/*
A: Qual o typeof de result?
- string
- number
- object
- function
B: Qual o resultado do log?
- result is not a function
- 1
- 2
*/
const myFn = () => {
const myNumber = 1
return () => myNumber + 1
}
const result = myFn()
typeof result // <- A
const result2 = result() // <- B
//------------------------------------------------------------------------------
/*
C: Qual o resultado do log?
- Uncaught TypeError: Assignment to constant variable.
- 1
- 2
*/
const object1 = {a: 1 }
object1.a = 2
console.log(object1.a) // <- C
//------------------------------------------------------------------------------
/*
D: Qual o resultado do log?
- Uncaught TypeError: Assignment to constant variable.
- 'olar'
- 'comovai'
*/
const a = 'olar'
let b = a
b = 'como vai'
console.log(b) // <- D
//------------------------------------------------------------------------------
/*
E: Qual o resultado do log?
- 3
- 1
- 2
*/
const object1 = { a: 1 }
const object2 = object1
object2.a = 2
console.log(object1.a) // <- E
//------------------------------------------------------------------------------
/*
F: Qual o resultado do log?
- 3
- 1
- 2
*/
const object1 = { a: 1 }
const object2 = { ...object1 }
object2.a = 2
console.log(object1.a) // <- F
//------------------------------------------------------------------------------
/*
G: Qual o resultado do log?
- 0
- undefined
- 1
H: Qual o resultado do log?
- true
- false
- ReferenceError: object1 is not defined
*/
const object1 = { a: [] }
const object2 = { ...object1 }
object2.a.push('string')
console.log(object1.a.length) // <- G
console.log(object1.a === object2.a) // <- H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment