This is the seventh day of my participation in the More text Challenge. For details, see more text Challenge
86. Which option is the method to set hasName to true if true is not passed as an argument?
function getName(name) {
const hasName = //
}
Copy the code
A. name B. name C. name D. name C returns an object wrapper, B returns the name itself, and D returns the length of the name.
87. What is the output?
console.log("I want pizza"[0])
Copy the code
B. String values can also be evaluated in a way similar to array subscripts.
88. What is output?
function sum(num1, num2 = num1) {
console.log(num1 + num2)
}
sum(10)
Copy the code
A) the value of the second parameter is the value of the first parameter. B) The value of the second parameter is the value of the first parameter.
89. What is output?
// module.js
export default() = >"Hello world"
export const name = "Lydia"
// index.js
import * as data from "./module"
console.log(data)
Copy the code
A) import * as is used to import all the exposure in module.js into the data object in index.js. B) Import * as is used to import all the exposure in module.js into the data object in index.js.
90. What is output?
class Person {
constructor(name) {
this.name = name
}
}
const member = new Person("John")
console.log(typeof member)
Copy the code
A: C, the instance object of the Person class belongs to object.
91. What is output?
let newList = [1.2.3].push(4)
console.log(newList.push(5))
Copy the code
D) The value returned by the push method is not a new array, but the length of the new array.
92. What is output?
function giveLydiaPizza() {
return "Here is pizza!"
}
const giveLydiaChocolate = () = > "Here's chocolate... now go hit the gym already."
console.log(giveLydiaPizza.prototype)
console.log(giveLydiaChocolate.prototype)
Copy the code
D) The prototype function has a prototype property. D) the prototype function has a prototype property.
93. What is output?
const person = {
name: "Lydia".age: 21
}
for (const [x, y] of Object.entries(person)) {
console.log(x, y)
}
Copy the code
A) Entries are an API for storing Object key-value pairs into A two-dimensional array. For details, see the following figure:
94. What is output?
function getItems(fruitList, ... args, favoriteFruit) {
return [...fruitList, ...args, favoriteFruit]
}
getItems(["banana"."apple"]."pear"."orange")
Copy the code
D) the extension operator must be placed in the last argument. D) the extension operator must be placed in the last argument.
95. What is output?
function nums(a, b) {
if
(a > b)
console.log('a is bigger')
else
console.log('b is bigger')
return
a + b
}
console.log(nums(4.2))
console.log(nums(1.2))
Copy the code
A: B, this problem is a little pit, mainly JS automatically at compile time to return the back add a semicolon, so never visit a + B, so choose B.
Title source
Github.com/lydiahallie…