1 How to determine whether the array type
<script> var arr=[1,2]; Console.log (arr.constructor= = =Array)</script>
The constructor can be used to determine whether an array type is available, but a more perfect method is described in Nowamagic, as follows:
<script> var arr=[1,2]; function IsArray (v) { return tostring.apply (v) = = = ' [Object Array] '; } Console.log (IsArray (arr))</script>
2 How to convert a variable to a string and a numeric type
Converting to a string can be converted to a value using ToString, number parseint
3 if (num& 1) {...} What does this judge mean?
NUM&1 is equivalent to NUM's binary number and 1 bitwise AND operation, when NUM is even, returns 1 when the return 0,num is odd.
&& | | is a logical operation that returns a Boolean value of,& and | is a bitwise operation.
Their biggest difference is,&& and | | It is short-circuiting,& and | Not short-circuited.
var a = 1;
var b = 1;
The former only executes to a>2 and b<2 is not executed, returning false
The latter execution a>2 will also continue to execute B<2, eventually returning 0
4 [' 1 ', 2,3].map (parseint) return what, why?
The return value is [1,nan,nan]
Map will pass three parameters to the function by default: The selected value in the array, the index of the selected value, the entire array executed
The parseint function has two parameters, the first is the value that needs to be converted, the second is the default of the binary, generally can be omitted, the default is decimal, so the above map to convert index as a binary number to get Nan;
5 for (Var i=4;i--;) {
SetTimeout (function () {
Console.log (i)},i*1000)
}, output what, why?
Output is-1-1-1-1
This examines the execution order and closure of the For loop, and the actual execution order of the For loop is as follows
<script> for (var i=0;i<4;i++) { console.log (i) } var j=0; while (J<4) { console.log (j); J+ +; } </script>
So we know the order of execution of the three conditions in the For loop, because the timer is used, all when the function in the timer is executed, the For loop is finished, at this time I is-1, so the output is four-1;
5 The difference between get and post in Ajax requires a precise description, and what does the Put Option Delete mean? What is this usage called?
Baidu a bit, speak very detailed
1. Get is the data that is fetched from the server and post is the data sent to the server.
2. Get is the URL where the parameter data queue is added to the Action property of the submission form, and the value corresponds to the field one by one in the form, which is visible in the URL. Post is the HTTP post mechanism that places the fields within the form with their contents in the HTML header, along with the URL address referred to by the Action property. The user does not see the process.
3. For Get mode, the server side uses Request.QueryString to get the value of the variable, and for post, the server side uses Request.Form to obtain the submitted data.
4. Get transmits a small amount of data, cannot be greater than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, the maximum amount of IIS4 is 100KB in 80KB,IIS5.
5. Get security is very low, post security is high. But the execution efficiency is better than the Post method.
Recommendation:
1, get the security of the method is less than the post, including confidential information, it is recommended to use the Post data submission method;
2, when doing data query, it is recommended to use Get method, and in the data to add, modify or delete, the proposed post method;
Official explanation
The http/1.1 protocol defines eight methods (sometimes called "actions") to indicate the different modes of operation of the resources specified by Request-uri.
Options returns the HTTP request method that the server supports for a specific resource. You can also test the functionality of your server with a request to send a ' * ' to the Web server.
The HEAD asks the server for a response that is consistent with the GET request, except that the response body will not be returned. This method allows you to obtain meta information contained in the response message header without having to transmit the entire response content.
GET makes a request to a specific resource. Note: The Get method should not be used in operations that produce "side effects", such as in Web apps. One of the reasons is that get can be accessed by web spiders and other casual.
POST submits data to the specified resource for processing requests (such as submitting a form or uploading a file). The data is included in the request body. A POST request may result in the creation of new resources and/or modification of existing resources.
PUT uploads its latest content to the specified resource location.
The delete request server deletes the resource identified by the Request-uri.
TRACE returns the request received by the server, primarily for testing or diagnostics.
The Connect http/1.1 protocol is reserved for proxy servers that can change connections to pipelines.
6 describe an infinite-level tree structure in JSON format
7 What is an event delegate? What are the advantages?
See http://www.webhek.com/event-delegate/
8 What is an event source, what is an event object, how to block event bubbling and the default time
Http://wenku.baidu.com/link?url= Evih7zxenmzmcgtj1o-xzbmqpqvfexplv-dto4w-8kakwtjes7ewnz9tf4v1rtvheygdgx5ksfmttx-xz5obsanrnjcqfpn7_wg09csmmks
Http://jingyan.baidu.com/article/ab0b5630ad88d0c15bfa7d7a.html
9javascript, there is a function, when performing object lookup, never go to find the prototype, this function is?
hasOwnProperty
JavaScript face question (i)