The answer
The answer
Js object knowledge examination
1. Which one is true?
const bird = {
size: 'small'
}
const mouse = {
name: 'Mickey'.small: true
}
Copy the code
- A:
mouse.bird.size
Is invalid - B:
mouse[bird.size]
Is invalid - C:
mouse[bird["size"]]
Is invalid - D: All three of the above options are valid
2. What is the output
const a = {}
const b = { key: 'b' }
const c = { key: 'c' }
a[b] = 123
a[c] = 456
console.log(a[b])
Copy the code
- A:
123
- B:
456
- C:
undefined
- D:
ReferenceError
3. What is printed next
var obj = {};
console.log(delete obj.p)
Copy the code
- A: true
- B: false
- C: error
- D: undefined
4. What does the following value print out
let obj = {name:'jimmy'.age:18}
let obj1 = obj;
obj.name = "chimmy"
console.log(obj1)
obj1 = {}
obj.age = 22
console.log(obj1)
Copy the code
- {name:’ Jimmy ‘,age:18}, {name:’ Jimmy ‘,age:18}
- B: {name: ‘chimmy, age: 18}, {}
- C: {name: ‘chimmy, age: 18}, {name:’ chimmy, age: 18}
- D: {name: ‘chimmy, age: 18}, {name:’ chimmy, age: 22}
4.1 What is the output
const obj = { a: 'one'.b: 'two'.a: 'three' }
console.log(obj)
Copy the code
- A:
{ a: "one", b: "two" }
- B:
{ b: "two", a: "three" }
- C:
{ a: "three", b: "two" }
- D:
SyntaxError
The above five questions are to investigate the basic knowledge of the object, if not all right, you can go to see my article JS object basic knowledge, review the basic knowledge of JS objects.
Data types and conversions
5. Please write the answers below
1.Js so far how many data types, please write out.2. NaN= = =NaN
3. typeof NaN
4. typeof null
5. typeof typeof 1
6. null= =undefined
7. ""= =0
8. 1 + null
9. '1' + null
10. Number(null)
11. Number("")
12.[] = =0
13.[] = =! []14.[] = =false
Copy the code
If you are not very good at it, you can see how much I know about js data types
Knowledge about wrapper objects
6. What is the output?
let a = 3
let b = new Number(3)
let c = 3
console.log(a == b)
console.log(a === b)
console.log(b === c)
Copy the code
- A:
true
false
true
- B:
false
false
true
- C:
true
false
false
- D:
false
true
true
7. Those values are false
0
new Number(0)
(' ')
new Boolean(false)
undefined
new Boolean(false).valueOf()
Copy the code
- A:
0
.' '
.undefined
.new Boolean(false).valueOf()
- B:
0
.new Number(0)
.' '
.new Boolean(false)
.undefined
- C:
0
.' '
.new Boolean(false)
.undefined
- D: all is false
If you are not very good at this, you can check out my article
Array Length
8. The following statement is true
let arr = [1.2.3.4.5];
let arr2 = [1.3]
Copy the code
- Arr. length = 3, and the array is [1,2,3]
- B: Execute arr[10] = 11; In this case, arr.length is 6
- C: Run delete arr[2]; Arr. length = 4, array = [1,2,4,5]
- D: arr2.length is 2
The above question is the array length related knowledge, if you master is not very good, you can look at my js array
Function points
9. What is printed correctly below is
var f = function () { console.log('1'); }
function f() { console.log('2'); }
f()
Copy the code
- A:1
- B:2
- C: error
- D: undefined
10. What is printed correctly below is
var a = 1;
var x = function () {
console.log(a);
};
function f() {
var a = 2;
x();
}
f()
Copy the code
- 2 A:
- B: 1.
- C: error
- D: undefined
The above question is the function name promotion and function scope related knowledge, if you are not very good, you can see my js function
Event Cycle knowledge points
11. The following output is correct
console.log('Start execution');
setTimeout(() = > {
console.log('timeout1')},0);
console.log("It's over.")
Copy the code
- A: Start execution, timeout1, end
- B: Timeout1, start execution, end
- C: Start execution, end, timeout1
12. The following output is correct
Promise.resolve().then(() = > {
console.log('Promise1')
setTimeout(function () {
console.log("setTimeout1")},10)})setTimeout(() = > {
console.log('setTimeout2')
Promise.resolve().then(() = > {
console.log('Promise2')})},10)
Copy the code
- A: Promise1, setTimeout1, setTimeout2, Promise2
- B: Promise1, Promise2, setTimeout1, setTimeout2
- C: Promise1, setTimeout2, setTimeout1, Promise2
- D: setTimeout2, Promise2, setTimeout1
Js Event Loop(Event Loop) js Event Loop(Event Loop) js Event Loop(Event Loop
Prototypes and prototype chains
13. The value printed below is
function A(){};
A.prototype.n = 1;
var b = new A();
A.prototype = {
n: 2.m: 3
}
var c = new A();
console.log(b.n);
console.log(b.m);
console.log(c.n);
console.log(c.m);
Copy the code
If you don’t understand this point, please refer to my article, which is explained at the end of the article.
This points to the question
14. What is the name value printed below
var name = "jimmy";
var a = {
name: "chimmy".fn : function () {
console.log(this.name);
}
}
a.fn();
Copy the code
15 The values printed below are, in order
var name = 'jimmy';
var student = {
name: 'chimmy'.doSth: function(){
console.log(this.name);
},
doSth2: function(){
var arrowDoSth = () = > {
console.log(this.name);
}
arrowDoSth();
},
doSth3: () = > {
console.log(this.name);
}
}
student.doSth();
student.doSth2();
student.doSth3();
Copy the code
Please refer to the passage “How much do you know about this?” for these two questions, they are taken from the passage.