What do you do with these JavaScript questions?

Source: Internet
Author: User

Topic 1

I look at this topic, I think the answer to choose B, in fact, the correct answer is D, know the reason? Then look down.

Map each element of the array calls the defined callback function and returns an array containing the result, and I think it will execute as follows:

function Testfuc (a) {        return  parseint (a);} Console.info (["1", "2", "3"].map (TESTFUC));

In fact, however, thesyntax for the callback function in map is as follows: function CALLBACKFN (value, index, arr), which can declare a callback function with up to three parameters. The first parameter is the value of the array element, the second argument is index, an array of array elements so; arr, the array object that contains the element.

So the fact that the topic executes is as follows:

function Testfuc (a,x) {        return  parseint (a,x);} Console.info (["1", "2", "3"].map (TESTFUC));

That is [parseint (1,0), parseint (2,1), parseint (3,2)] So the final answer is [1, nan, nan]

Topic 2

This topic is relatively simple, the answer is a

typeof is used to obtain a variable or expression type, typeof generally can only return the following results: number,boolean,string,function (function), object (NULL, Array, object), undefined.

Instanceof Indicates whether a variable is an instance of an object, and Null is a special value of type Object that represents the meaning of a null reference. But null returns object this is actually an error in the implementation of the original JavaScript

Topic 3

In fact, the first part of this topic is implemented as follows (the POW () method can return the value of X's Y Power):

function testfuc (x, y        ) {+ ":" +y        ); return Math.pow (x, y);} Console.info ([3,2,1].reduce (TESTFUC));

Note, however, that the parameters of the POW are mandatory, [].reduce (Math.pow), which is equivalent to executing math.pow (); causes an error

So the answer to the question is a .

Topic 4

This topic believes that many people will, the topic will be executed string concatenation, and then perform three operations, so the answer is a

Topic 5

I believe you see Uncle Tom's JavaScript series of articles will know that JS has variables in advance declaration, but not in advance to assign value

So the answer above is a .

Topic 6

This topic, I do not understand the reason, but the book explains that:

The filter is exposed to elements that are not assigned, that is, in arr, the length is 10 but the actual numeric element list is [0, 1, 2, ten], and therefore eventually returns an empty array []

So the correct answer is C .

Topic 7

The answer to this question is C .

We all know that the addition or subtraction of two floating-point numbers will result in a certain normal data conversion caused by the loss of precision Eight-six = 0.20000000000000007.

The decimals in JavaScript is represented by a double-precision (64-bit) , consisting of three parts: the character + order + the tail number, 1/10 in the decimal, which can be simply written as 0.1 in decimal, but in binary, He had to write: 0.0001100110011001100110011001100110011001100110011001 ... (Back all 1001 loops). Because the floating-point number has only 52 valid digits, it is rounded off from the 53rd bit. This causes the problem of "floating point precision loss".

The more rigorous approach is (eight-six). TOFIEXD (1) or use the Math.Round method to return to integer operations.

Determine if two floating-point numbers are equal, or suggest approximation comparisons, such as if ((a) < 1E-10)

Topic 8

Maybe everyone thinks the answer is a, but the answer is C, for what, in fact, you can print out the value in the function, you know what's in the end.

Using the new String (), a new object is used as the value of the this variable using the constructor call, and the result of the call is implicitly returned

Topic 9

Believe that if you understand the above question, this topic is simply too easy, the answer is a

The variable created directly by invoking string ("a") is the same as "a".

Topic 10

It's a little dizzy to see the subject, but in fact

function Issane (num) {  return isEven (num) | | isodd (num);}

The function determines whether NUM is a positive integer, ' 13 ' is cast to a value 13,-9%2 the result is -1,infinity%2 is Nan

So the answer is C .

Topic 11

The answer is D .

the parseint () function parses a string and returns an integer. When the value of the parameter radix is 0, or if the parameter is not set , parseint () determines the cardinality of the number based on string .

Topic 12

The answer is a .

To illustrate here,

Array.prototype for [],array.isarray (a) is a method of judging whether a is an array

A method that determines whether an object is an array:

1) ES5 function IsArray (), which tests whether an object's internal [[Class]] property is an array:
Arrray.isarray (a);
2) Determine if the object's constructor is an array:
A.constructor = = = Array
3) Create a result string using the object's internal [[Class]] Property:
Object.prototype.toString.call (a)
4) Use the instanceof operator to test whether the object inherits from array: (but because a page's IFRAME does not inherit an iframe from another page, the method is unreliable)
A instanceof Array

Topic 13

This is relatively simple, you'll be a little more careful, and see if you're doing the right thing.

In the IF condition judgment statement relative to the = = Comparison loose, as long as if (n), n is not a null,0,undefined value, will be converted to true. Enter Console.info (A = = True); return false

Which means the answer is B .

Topic 14

The answer is Bbecause the array is an object in Javascript, and objects using == comparisons are references to comparisons. Simply put, that is, if it is the same object, it is equal, and if it is not the same object, it will be different. Each use [] is a new array object, so [] == [] there are two data objects in the statement, and they are not equal to each other.

Topic 15

I believe you can do the right thing if you know the + number in JavaScript, the answer is a .

Execute ' 5 ' +3, plus with the concatenation string function, will cast 3 to the string ' 3 ' and ' 5 ' stitching.

Execute ' 5 '-3, minus sign only has the function of numeric arithmetic, therefore will convert ' 5 ' to numerical value, perform 5-3 numerical operation

Topic 16

The answer is D .

Differentiate assignments and declarations. Although var arr = array (3), it only creates an array of length 3, and the latter sentence only assigns a value to the first element, so the actual length of ARR is 1, that is, there is only one element that eventually participates in the map, and the result returns

Topic 17

The end result is 10+1+10

So the answer is D .

Topic 18

The answer is B, do you guess right??

The reason is that the exact integer for JavaScript is: Math.pow (2,53)-1 =9007199254740991.

var a = 111111111111111110000,
max = 9007199254740992;

The value of a is greater than the maximum integer precision that JavaScript can represent, so adding to any number will result in distortion.

Topic 19

We'll find out in the console a test.

So the correct way to call it should be: X.call ([])

The answer goes without saying C

Topic 20

In JavaScript, the minimum value represented by Number.min_value is 5e-324,min_value, which is not a negative minimum, but a number closest to 0, so number.min_value>0.

The negative minimum value can be expressed using-number.max_value.

The answer is a .

Topic 21

That's not much, the answer is a .

1<2, which returns True, executes true<3, which forces the conversion of true to 1,1<3 and eventually returns true.

3<2, returns FALSE, executes false<1, forces false to 0,0<1, and eventually returns true.

Topic 22

Using A==B to determine whether a and B objects are equal, you can cast a B object to the type of a object, that is, execute 2 = = [[[2]]], and implicitly call parseint ([[[[[[[[[]]]]) to force [[[[]]] to convert to a number base, which is 2,2==2, and

The answer is a .

Topic 23

Execute within the immediate call function, var x1 =y1 = 1; Create local variable x1 and global variable y1. Attempting to access variables inside the function outside of the function will result in an error.

So the answer to choose C

What do you do with these JavaScript questions?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.