Some basics of JavaScript one

Source: Internet
Author: User
Tags html form html form input

1, the understanding of JS

A, developed by Netscape (Netscape) b, which is a cross-platform scripting language C, applied to Web pages, to operate the browser and Web content D, JavaScript was originally designed to verify the correctness of HTML form input

2, JS of the three major components

A, ECMAScript: A specification of B, BOM (browser) object model: Browser object Model C, DOM: Document Object Model

3, JS introduced the way

A, <div onclick= "alert (1)" ></div> B, write at <script></script> <script> alert (1) </script> c, write in JS file <script src= "Js/index.js" ></script>

4, JS's comments

A, single-line comment://b, multiline comment:/**/

5. The naming rules of variables in JS

A, rules: numbers, letters, underscores, $ symbols, which cannot begin with a number B, declaration: You can not use keywords and reserved words C, suggestions: see the name of the meaning of D, naming method: Hump naming method, regular naming (_ connection), Hungarian name

6, the data type in JS

JS data types are divided into: basic data type, complex data type basic data type: number string Boolean null undefined complex data type: Object

7, NULL, true false converts the value to a number

A, false if converted to a number is 0 B, true if converted to a number is 1 C, null if converted to a number is 0

8, the type conversion in JS

Type conversion in a, JS is divided into: forced type conversion Implicit type conversion B, coercion type conversion: number parseint parsefloat C, implicit type conversion: arithmetic operator:-*/% assignment operator:-= *=/=%= Relational operators: = = =!

9, the understanding of Nan

A, not a number is not a digit B, Nan only represents not a number, itself and itself are not equal (nan! = Nan) c, how to determine if Nan:isnan===> is Nan, returns True, otherwise returns false d, the data type of Nan is num ber

10. The difference between i++ and ++i

A, i++: first Use, in addition 1 B, ++i; Add 1 First, in use

11. The value that can be converted to false in JavaScript

0 ' null undefined false

12, JavaScript inside the + number

A, the addition of any string to the data following the plus sign will become link B, if the value added to undefined is Nan

13. If the accepted data type is judged

The condition of the non-Boolean type determines if (2) Number type------> all non-0 digits represent True, 0 represents false if ("ABC") string type-------> all non-empty strings are Represents true, "" represents false if (obj), the object type--------> all non-null objects represent true,null on behalf of False if (undefined)------ , False if (NaN)--------> represents False if (function)---------> If the function exists, represents true

14. Optimization of If statement

A, put the number of conditions and execution results to the front B, reduce the first useless judgment, you can use nested judgment C, Judgment statement prohibit three times nested

15, the understanding of switch

A, switch parentheses inside a variable B, the value of the case corresponds to a value of the variable c, switch inside the variable and case this variable 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 D, 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 E, 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 the user's experience is more perfect, on the other hand, the code of the future maintenance also has a lot of help F, the value of the comparison is a fixed value

16. Application scenarios for if and SWICTH

IF:A, the specific value of the judgment B, interval of the judgment C, the result of the operation is a Boolean expression to judge true flash switch: A, to determine the specific value of B, the number of values is fixed for a few fixed values to judge, we recommend the use of a switch statement. Because the switch statement loads specific answers into memory, it is relatively efficient to use code-based readability: If-else is easy to read when conditions are low, and switch is easier to read when conditions are high

17. The currently known escape character

A, \ "B, \" C, \ n means newline D, \ t Tab key

18. Syntax of three-dimensional expressions

Conditions? Value 1: value 2;

19, the concept and significance of the cycle

A, what is a loop?       Repeat an action or some statement (code block) b, what does a loop do? Simple code that handles repetitive actions is typically used to iterate over arrays, JSON objects, element collections

20, while need to pay attention to the place

A, initialize a variable B, while () parentheses inside is to determine the condition C, in addition to executing the corresponding code in the code block to change the loop body condition variable = = "in {} change

Some basics of JavaScript one

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.