Skip to content

🔭 Some basic questions about the JavaScript language.

License

Notifications You must be signed in to change notification settings

glhrmoura/js-quiz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Quiz

I have compiled some basic JavaScript language questions so developers can test their knowledge, and also learn some nuances of the language from the detailed answers to each question.

The repository is open to contributions, whether new questions or even translations of answers into other languages.

A few notes about the code

  • Assuming ECMAScript 6;
  • Every snippet is run as a global code;
  • The code is not running in strict mode.

1. What is the result?

('b'+'a'+ +'a'+'a').toLocaleLowerCase()

a) SyntaxError
b) 'baaa'
c) 'banana'
d) 'baa'

2. What is the result?

let num = '10'

num += num++

a) '1010'
b) NaN
c) '1011'
d) 21

3. What is the result?

(function () {
  let num1 = 10
  let num2 = 20

  return sum()

  function sum() {
    return num1 + num2
  }
})()

a) undefined
b) NaN
c) 30
d) ReferenceError

4. What will be the output value of log 1 and log 2?

function Person (firstName, lastName) {
  this.firstName = firstName
  this.lastName = lastName
}

let person = Person('Guilherme', 'Moura')

console.log('log 1: ', person)
console.log('log 2: ', firstName, lastName)

a) log 1: Guilherme Moura | ReferenceError
b) log 1: undefined | log 2: Guilherme Moura
c) log 1: { firstName: 'Guilherme', lastName: 'Moura' } | log 2: Guilherme Moura
d) log 1: { firstName: 'Guilherme', lastName: 'Moura' } | ReferenceError

5. What is the result?

(3,5 - 3) * 2

a) 0.999999
b) 0,5
c) 1
d) 4

6. What is the value of the object?

let card = {};

(['audi','bmw'].map(item => card[item] = undefined), card)

a) {}
b) { audi: undefined, bmw: undefined }
c) ['audi','bmw']
d) [{ audi: undefined }, { bmw: undefined }]

7. What is the result?

Object.prototype.toString.call([1, 2, 3, 4, 5])

a) '[object Array]'
b) '1,2,3,4,5'
c) undefined
d) '[object Object]'

8. What is the result?

let john = { name: 'John' }
let array = [john]

john = null

array[0].name

a) TypeError
b) null
c) 'John'
d) undefined

Check the detailed answers to each question 📝

License

MIT

Copyright (c) Guilherme Moura

About

🔭 Some basic questions about the JavaScript language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published