js test questions and answers (5)

1. Multiple choice questions (30 questions in total, 2 points for each question)
1.
Port A that does not fall under the same-origin policy restrictions.
Protocol
C Domain name
D URL
Correct answer: D
2. Does not belong to 23 common design patterns
A Single case
B MVC
C Observer
D strategy
Correct answer: B
3. There is code function Foo(){}; var foo = new Foo(); The option for the following expression to be true is
A Foo.prototype == Foo.proto
B foo .prototype == Foo.proto
C foo.proto == Foo.prototype
D foo.proto == Foo.proto
Correct answer: C
analysis:
foo.proto == Foo.prototype
The proto__ attribute of the instance points to the constructor prototype
4. Which of the following operators or methods can be used to determine that an instance belongs to a certain class
A typeof
B instanceof
C isPrototypeOf
D hasOwnProperty
Correct answer: B
analysis:
Instanceof can determine that an instance belongs to a certain class
5. Which of the following keywords can realize the inheritance of the class
A inherit
B extends
C public
D interface
Correct answer: B
analysis: extends inheritance in es6
6. Regarding the prototype object, the following statement is wrong is
A Every function has a prototype object
B Every constructor has a prototype object
C The properties and methods on the prototype object can be accessed by instances
D The properties and methods on the prototype object can be accessed by subclasses (in the code)
Correct answer: D
Analysis:
The properties and methods on the prototype object can be accessed by the instance
7. There is code function foo(){ var a=10; return function(){ console.log(a++)}} foo()(); After running, it will Print
A 10
B 11
C function body
D in the console and report an error.
Correct answer: A
analysis:
a++, after adding, first assign and then add
8. The commit command in the version management tool svn is
A push
B add
C commit
D update is
correct Answer: C
analysis:
The submission command in svn is commit
9. There is code function Foo(){ this.name="test1"; function bar(){ this.name="test2" }; bar();} Foo.name = "test3" ; var foo = new Foo(); Ask the value of foo.name to be
A test1
B test2
C test3
D undefined
Correct answer: A
resolution:
var foo = new Foo()
foo is an instance of Foo, all foo.name prints the result That is test1
10. The following jquery object methods return boolean values ​​are
A not()
B has()
C hasClass()
D fiter()
Correct answer: C
analysis:
hasClass() has a class name that returns true, but does not return false
11. Which of the following is not a method for jquery to perform document operations:
A append()
B inner()
C wrap()
D clone()
Correct answer: B
analysis:
inner() is not
12. Regarding the jquery plug-in, the description is wrong
A Use jquery plug-in can improve development efficiency
B jquery plug-in can call through jquery object
C jquery plug-in can not achieve chain call
D jquery plug-in generally needs to consider parameter setting problem
correct answer: C
analysis:
as long as the return value is an object in jq, it is Can be called in chain
13. The length attribute of the
function is the number of rows of the A function, the number
of parameters of the
function C, the number of functions returned, and the number
D is always 0.
Correct answer: B
analysis:
the length of the function is the number of parameters
14. Use of the function Return can not return which of the following
A function
B object
C value
D for loop
Correct answer: D
analysis:
function can only return data and cannot return to loop
15. The following statement is wrong is that
A closure refers to the right to access another function in the scope The
most common way of function B closure of the variable is to create another function within a function.
C closure can be cleaned up by the garbage collection mechanism
D. The function can reference external parameters and variables.
Correct answer: C
analysis:
closure is not Can be cleaned up by garbage collection mechanism
16. The output of the following code is var a; var a = [1,2,3]; function a(a){ a[1] = 5;} a(a); console.log(a);
A [ 1,2,3]
B [1,5,3]
C Error
D undefined
Correct answer: C
17. The following arrow function is written correctly is
A 0–{}
B a,b => {}
C _ =>
D caller
Correct answer: C
18. The wrong statement about this
is that the function of A this is the event processing function, this is the event source
B the function of this does not have a definite subordinate object, then this is the window object
C Let a = 123; Then this in this.a means that
when the function of the window object D this is the constructor, this is the new object.
Correct answer: C
19. In the constructor, you can add a method after a property, which is
A prototype
B prototype
C proto
D prototype
Correct answer: B
20. In ES6 (2015), which is the noun that did not exist before
A function
B class
C recursive
D process
Correct answer: B
21. Which binding of event delegation can be used in jQuery
A add
B on
C bind
D click
Correct answer: B
22. Which of the following methods cannot initiate asynchronous requests
A $.get()
B $.post( )
C $.json()
D .ajax() Correct answer: C analysis: A, B, and D are all asynchronous request methods of the jquery class itself. Ajax() in the option C option. Correct answer: C analysis: A, B , D are the asynchronous request method of the jquery class itself. The .json() option in the C option is the interference item, and there is no such usage.
23. Which of the following methods cannot change the point of this inside the function
A bind
B change
C apply
D call
Correct answer: B
Analysis:
Bind call apply can change the this point, pay attention to the difference in use
24. Prototype chain
A Each object that inherits the child function of the parent function contains an internal property _prototype. This attribute contains a pointer to the prototype of the parent function. If the _proto_ property of the prototype object of the parent function is a function of the next higher level. In this process, the prototype chain
B is formed. Each object that inherits the child function of the parent function contains an internal property _proto. This attribute contains a pointer to the prototype of the parent function. If the prototype_ property of the prototype object of the parent function is a function of the next higher level. In the process, a prototype chain is formed
C Each object that inherits the child function of the parent function contains an internal property _proto_. This attribute contains a pointer to the _proto_ of the parent function. If the _proto_ property of the prototype object of the parent function is a function of the next higher level. In this process, the prototype chain
D is formed . Each object that inherits the child function of the parent function contains an internal property _proto_. This attribute contains a pointer to the prototype of the parent function. If the _proto_ property of the prototype object of the parent function is a function of the next higher level. In this process, a prototype chain is formed.
Correct answer: D
analysis:
principle question, the prototype chain is maintained by __proto__, and the top points to Object.prototype
25.es6 inherited grammar
A class
B class extends
C class.prototype
D class extend
correct answer: B
analysis:
grammatical questions such as class A extends B{}
26. The possible cause of a 404 error when viewing a webpage with a browser is () means that the webpage does not exist and the file is not found. The
source code of the page is wrong.
B the file does not exist.
C Error in connection with the database
D Insufficient permissions
Correct answer: B
27. The status attribute of the XMLHttpRequest object represents the http status code of the current request, and () represents the correct return.
A 200
B 301
C 500
D 404
Correct answer: A
resolution:
500 server error, 301 redirect, 404 request resource not found
28.function People(name, age) {this.name = “xixi”, this.age = 18 return {}} var obj = new People(); What is the return value (obj) after the People function is called by new?
A {}
B {name: “xixi” age: 18}
C Error
D Function body itself
Correct answer: A
analysis:
return object takes precedence over instance return Level higher
29. The result of executing the following program is function fn3() {arguments.callee.play();} fn3.play=function () {console.log("aaa"); }; fn3()
A error
B Null value
C play
D "aaa"
Correct answer: D
Analysis:
Use of callee
30. The result of the following operation is false is function Box(){this.name='zhang';} function Desk(){this.age= 100;} function Table(){this.lever=1000} Desk.prototype=new Box();//Inherited through the prototype chain var desk=new Desk(); var table=new Table();
A alert(table instanceof Object)
B alert(desk instanceof Box);
C alert(Desk instanceof Box);
D alert(desk instanceof Desk);
Correct answer: C
analysis:
A. Everything is an object
B. Dest inherits Box, So correct
C. Desk is an instance of Function, and has nothing to do with Box
D. desk is an instance of Desk
2. Multiple choice questions (indefinite choice) (20 questions in total, 2 points for each question) 1.
Which of the following methods are used to create objects in js Several types of
A can create objects through json
B can create objects through the new keyword
C can create objects through function calls
D objects cannot be created through function calls
Correct answer: A, B, C
2. The following about the constructor Advantages, describe the correct
A constructor that can create objects through the new keyword. The creation of objects is relatively standard.
B The constructor can only create one object.
C can solve the problem of code duplication when multiple objects of the same type are created.
D Created by the constructor Object, the created object is equal.
Correct answer: A, C
3. The correct description of apply and call inheritance is
that the second parameter of the A call method is not fixed
The second parameter of the B call method can only have one
. The second parameter of the C apply method is an array. The second parameter of the
D apply method is not fixed.
Correct answer: A, C
4. When using the new operator to generate an instance, The steps that need to be performed are those
A create a new object
B change this point to
C execute the code in the constructor
D return an object
Correct answer: A, B, C, D
analysis:
when the code new Foo (...) is executed, it will happen The following things:
A new object inherited from Foo.prototype is created.
Call the constructor Foo with the specified parameters, and bind this to the newly created object. new Foo is equivalent to new Foo(), that is, if no parameter list is specified, Foo is called without any parameters.
The object returned by the constructor is the result of the new expression. If the constructor does not explicitly return an object, the object created in step 1 is used. (Under normal circumstances, the constructor does not return a value, but the user can choose to actively return the object to cover the normal object creation steps)
5. The method to remove the jquery object in jquery is
A remove
B detach
C empty
D clear
Correct answer: A , B, C
analysis: the
first three are ok, clear is not good
6. The following statement about jquery is correct is that
A jquery can be used in combination with native js
B jquery object and native DOM object cannot be converted to each other
C jquery object can use native js method
D native DOM object cannot use jquery object method
Correct answer: A, D
analysis:
jquery object cannot use native js method
7. Object setting properties The correct method of the attribute value is
A obj.name=3
B obj["name"]=3
C obj{name} = 3
D Obj->name=3;
Correct answer: A, B
8. Get the object in jquery The correct way is
A $()
B jQuery()
C jquery()
D $jQuery()
Correct answer: A,B
9. The case code is as follows:

Large font
Small font
Please select the div object whose text is "big font"
A $("div.big");
B $("div .big")
C $("div:contains('big font')");
D $("form> div.big");
Correct answer: A, C, D
Analysis:
This question examines the usage of different selectors.
Option B is to select a collection of jquery objects with the big class name (descendants) in the div
10. About Prototype prototype and prototype chain statement is correct is that
the inheritance mechanism of A Javascript is based on prototypes, not Class
B. All objects created by new Function() are function objects, and the others are ordinary objects.
C ordinary objects have no prototype, but there are The __proto__ property
D prototype property (object) will get a constructor (constructor function) property by default. This property is a pointer to the function where the prototype property is located.
Correct answer: A, B, C, D
11. Why use jQuery? What are the benefits of jquery
A It has a powerful selector, excellent DOM operation encapsulation
B Excellent browser compatibility
C Perfect ajax
D Has a reliable event handling mechanism
Correct answer: A, B, C, D
analysis:
The biggest feature of jquery is the query, and it encapsulates a large number of methods for DOM operations, event processing and ajax requests.
12. The following is the design mode:
A, singleton mode,
B, observer mode,
C, test mode,
D, view mode,
correct answer: A, B
analysis:
singleton mode and observer mode, which are common design patterns
13. What are the
A types of jq selectors?
B id
C tags
D can be all of the above
Correct answer: A, B, C, D
analysis:
selectors in css Both can be used in jq.
14. When the state of the XMLHttpRequest object changes, call the callBackMethod function, the following is incorrect ()
A xmlHttpRequest.callBackMethod=onreadystatechange;
B xmlHttpRequest. onreadystatechange(callBackMethod);
C xmlHttpRequest. onreadystatechange(new function( )(callBackMethod });
D xmlHttpRequest. onreadystatechange = callBackMethod
Correct answer: A, B, C
analysis:
When the state changes, the onreadystatechange event is triggered, and the callBackMethod event handler can be bound to the changed attribute.
15. Which of the following are common data types of mysql ()
A varchar
B int
C float
D text
Correct answer: A,B,C,D
16.jquery binding event method has
A one
B bind
C addEvent
D on
Correct answer: A, B, D
analysis:
addEvent is not an event
17. Jq's dom addition, deletion and modification operations include
A append
B appendTo
C remove
D detach
Correct answer: A, B, C, D
Analysis:
Several are methods of dom operation
18. The operations on the class attribute of operating element nodes in jq are
A addClass
B removeClass
C attr("class", "box")
D setClass
Correct answer: A, B, C
Analysis:
A is to add the class name
B is to delete the class name
C is to switch the class name
19. The following can achieve inheritance:
A constructor inherits
B Object.create()
C prototype chain inherits
D es6 extends
Correct answer: A, B, C, D
analysis: the
first three are inherited from es5, and the last one is from es6 Inherit
20. The result printed after executing this program forEach=function (arr,fn) {for(var i=0,l=arr.length;i<l;i++){ var c=arr[i]; if(fn .call(c,i,c)===false){ return false;}} }; function box1(index,num) {console.log(index,num);} var arr=[10,9,8, 7,6,5,4]; forEach(arr,box1)
A 0 10
B 3 7
C 2 4
D 5 5
Correct answer: A,B,D

Guess you like

Origin blog.csdn.net/weixin_49299412/article/details/108106716