JavaScript basic syntax

Source: Internet
Author: User
Tags object model

001. How to understand heap and stack?JS variables are stored in the stack storage and heap storage, the basic data types of variables stored in the stack, reference data types of variables stored in the heap reference type data address also exists in the stackwhen accessing the underlying type variable, the value is taken directly from the stack. When accessing a reference type variable, the address is read from the stack and the data is fetched from the address to the heap002, the data types in JS are divided into which categoriesbase data type: number string undefined null BooleanReference data type: Object003. Forced-type conversion and implicit type conversion in JSimplicit type conversion: = = = =-*/% *=/=-=%= Coercion Type conversion: Number parseint (): Rounding conversion parsefloat ()004, JavaScript three major components1, ecmascript==== "It is a standard to build a car------" a specification of the engine JS2. Bom:browser object model===> Browser objects model3. Dom:document===> Document Object Model005. What is the difference between undefined and null? First, remember what you don't understand.NULL is an object that represents "none", and a value of 0;undefined is a primitive value that represents "none", and a value of Nan when converted to a number. undefined:(1) The variable is declared, but when it is not assigned, it is equal to undefined. (2) when calling a function, the argument that should be supplied is not provided, which equals undefined. (3) The object does not have an assigned property, and the value of this property is undefined. (4) When the function does not return a value, undefined is returned by default. null:(1) as a function parameter, the parameter of the function is not an object. (2) as the end point of the object prototype chain. 006. Talk about your understanding of NanA, not a number is not a digitB, Nan only represents not a number, itself and itself are not equal (nan! = Nan)C, how to Judge Nan isnan===> if it is Nan, return true, otherwise return False Number.isnan ()the data type of D, Nan is number007, the difference between i++ and ++ii++: First Use, in addition 1++i; Add 1 First, in use008. What are the values that JavaScript converts to false? 0 ' null undefined false009, NULL, True false the value to convert to a number is how muchFalse if the conversion to a number is 0.true if you convert to a number, it's 1. NULL if converted to a number, it's 0.010. What are the values that JavaScript can convert to true?A number other than 0 is a non- empty string True to a non-nullLike    011, if statement optimization  1, the number of conditions and execution results put to the front  2, reduce the first useless judgment, you can use nested judgment  3, the judgment statement prohibit three nested    012, talk about your understanding of switch  1, switch parentheses inside a variable    2, the value corresponding to the case is a value of this variable  3, This variable in switch and case inside does not have an implicit type of conversion, but an identity comparison. So be sure to note that this variable and the value in this case is not a type of  4, about the switch inside the case will have a penetration effect, this effect will sometimes bring us benefits (see the last example), sometimes it will bring us bad, If this penetrating effect is not required, add break 5, swicth inside if the variable does not match the value in the case, then you need to return a message. So at the end of the case must add a default, so that both the user's experience is perfect, on the other hand, the code of the future maintenance also has a great help  6, the comparison value is fixed value  013, if and SWICTH application scenarios    If:            1, specific values to judge              2, interval judgment             3, the result of the operation is a Boolean expression to judge   true    false switch:            1, judging specific values             2, the number of values is fixed               for several fixed value judgments, it is recommended to makeUse the switch statement. Because the switch statement loads specific answers into memory, it's relatively efficient             code-based readability: if the conditions are low, if-else is easy to read, With more conditions, switch is easier to read  014, the escaped character  \ " \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  tab"  015, while needing attention  1, Initializes a variable  2, while () in parentheses, which determines the condition  3, except for the condition variable that changes the loop body in the code block besides executing the corresponding code = = = "Change  016 in {}, The use of the Do-while loop and the difference between the while  do-while () regardless of whether the condition is set at least once, and the same as the while rule, the only difference is that the do{}while is executed first (after executing the judgment  017, Let's talk about your understanding of the For loop  for (the first is: The loop variable is also the initialization variable; the second is to judge the cyclic condition; the third is to change the cyclic variable) {      code block}  loop variable: A variable that controls whether the loop ends (assigning an initial value to a variable, and only one time) the loop condition: Determines whether the loop continues (every time it executes) changing the loop variable: used to change the loop variable (executed each time) the difference between  018, while, and for The  for loop is known for the number of cycles, while the number of cycles is not known  for limits the number of cycles  while is the difference between conditional loop  019, break, and continue  return   Continue:continue just aborts the cycle, and then begins the next loop, which can only appear in the loop  break:break used to completely end a loop, jumping out of the loop body is not executing the code below the break, only appears in the selection or loop   Return: Returns the value of the function, does not execute the code below the return, can only appear in the function   020, let the function execute what kind of way  1, JS is an event-driven language, so you can call the function by JS event to let the function execute  2, direct write function name plus ()  3, execute function immediately. After the literal function ({} plus ())  021,Several ways to define functions  1, keyword functions: function fnname () {}; 2, literal function: var fn = function () {}; 3, constructor: var fn = new function ()  022, function  1, reduce code writing (code reuse)  2, hide processing details, easy to modify and maintain  3 in the future, control the timing  023, talk about your understanding of parameters  1, parameter is divided into: formal parameter and argument  2, with parameters can make the function become more flexible  3, formal parameters and arguments to each corresponding  4, if the corresponding parameter does not pass value, then the value is undefined  024, what is the scope chain?  1, simply said, scope collection   Current scope--parent scope--global scope   formed scope chain   global scope variables and methods can be called   Local variables and methods can only be called locally (except for closures)   Local can access global variables and methods  025, Console.log and Console.dir differences  console.log () can replace alert () or document.write (), the message is printed in the browser console when you use Console.log () in a Web page script.  console.dir () can display all properties and methods of an object.  026, talk about your understanding of arguments.  1, an object inside the function  2, stores all the arguments  3, can use [] and subscript to access the contents of the arguments   arguments[ 0]   Access the first argument  4, you can use  arguments.length to determine the number of incoming arguments  5, the most common use: To determine the number of parameters passed in (depending on the number of parameters do different things)    027, please say JS compile and execute  1, JS pre-compile:     a, the Var and function defined variables to the top of the script      b, An assignment statement is not promoted, even after the equals sign is a function2, JS execution: code from the top down to execute  028, a simple explanation of JS variable declaration promotion   Variable declarations and function declarations from their code where the position is moved to the top of the execution environment, this process is called promotion   only the declaration operation will be promoted, Assignment and logical operations are left in place waiting to be executed the  JS compiler will consider the variable declaration as two parts, namely the declaration operation (Var a) and the assignment operation (a=2)

JavaScript basic syntax

Related Article

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.