This is the 9th day of my participation in Gwen Challenge

106. Output what?

const colorConfig = {
  red: true.blue: false.green: true.black: true.yellow: false,}const colors = ["pink"."red"."blue"]

console.log(colorConfig.colors[1])
Copy the code

D, when JS accesses an attribute of the object through a dot, it will treat colors as an attribute, find undefined, and then call [1] will return an error.

107. Output what?

console.log('❤ ️'= = ='❤ ️')
Copy the code

A: Obviously these two literals are equal.

108. Which methods modify the original array?

const emojis = ['✨.'🥑'.'😍']

emojis.map(x= > x + '✨)
emojis.filter(x= >x ! = ='🥑')
emojis.find(x= >x ! = ='🥑')
emojis.reduce((acc, cur) = > acc + '✨)
emojis.slice(1.2.'✨) 
emojis.splice(1.2.'✨)
Copy the code

A: Map,filter,slice return a new array, find returns an element of the array, reduce returns a value, and only splice changes the array.

109. Output what?

const food = ['🍕'.'🍫'.'🥑'.'🍔']
const info = { favoriteFood: food[0] }

info.favoriteFood = '🍝'

console.log(food)
Copy the code

A, the above code only modifies the value in info and does not have any effect on the food object.

110. What does the following function do?

JSON.parse()
Copy the code

A: This question depends on our knowledge of the common JavaScript APIS, which convert JSON strings to the corresponding JavaScript values.

111. Output what?

let name = 'Lydia'

function getName() {
  console.log(name)
  let name = 'Sarah'
}

getName()
Copy the code

D) In this case, there is a temporary dead zone. If you call the variable defined by let in the temporary dead zone, an error will be reported.

112. Output what?

function* generatorOne() {
  yield ['a'.'b'.'c'];
}

function* generatorTwo() {
  yield* ['a'.'b'.'c'];
}

const one = generatorOne()
const two = generatorTwo()

console.log(one.next().value)
console.log(two.next().value)
Copy the code

A) next().value b) next().value C) next().value D) next().

113. Output what?

console.log(`${(x => x)('I love')} to program`)
Copy the code

A) the template string in braces is A function that executes immediately.

114. What will happen to the following function?

let config = {
  alert: setInterval(() = > {
    console.log('Alert! ')},1000)
}

config = null
Copy the code

A: C, this is because the parameters in the cycle timer is an arrow function, within the context of the arrow function is bound to the config, through the value is null, the callback function remains a reference for the config, so the cycle timer will not stop, is every 1 seconds to continue printing, can be cancelled by the clear the cycle timer.

115. Which of the following methods returns ‘Hello World! ‘?

const myMap = new Map(a)const myFunc = () = > 'greeting'

myMap.set(myFunc, 'Hello world! ')

/ / 1
myMap.get('greeting')
/ / 2
myMap.get(myFunc)
/ / 3
myMap.get(() = > 'greeting')
Copy the code

A: B, first we need to clarify that the Map value is Hello world! 1,2,3,3 is a new address, so choose B.

Title source

Github.com/lydiahallie…