Note I. First knowledge of Javascript

Source: Internet
Author: User

First, the initial knowledge of Javascript

JavaScript is a scripting language designed for interacting with Web pages . Consists of three parts:
ECMAScript (ECMA-262 definition): Provides core language features
Document Object Model (DOM): provides methods and interfaces for accessing and manipulating Web page content
Browser Object Model (BOM): Provides methods and interfaces for interacting with the browser
The three components of JavaScript are supported by varying degrees in the current five major browsers (IE, FireFox, Chrome, Safari, Opera). Basic all browsers generally support ECMAScript third edition. But the support for Dom and BOM is a lot worse compared

JavaScript is a scripting language that can be used in combination with HTML markup languages, and its programs can be written to interpret execution directly in the browser.
JavaScript is an interpreted language (precompiled, executed)
The international standard for JavaScript is ECMAScript.
syntax, type, statement, keyword, reserved word, operator, object
How do I use JavaScript?
Inserting a scripting language in an HTML document can use the <script> tag
<script> tags can be placed anywhere on the page and are generally defined in the <script> Tag Properties!
Type, SRC, defer, CharSet


1.1. Variables

Variable
JavaScript is a weak type of scripting language
var c = 3; that is, the declaration of the variable (the variable must be added to the Var declaration before it is used, the programming specification)
Naming rules for variables!
1. Variable naming must begin with a letter or subscript symbol "_" or "$".
2. The variable name cannot exceed 255 characters in length.
3. Spaces are not allowed in variable names.
4. Do not use the reserved keywords and reserved symbols in the scripting language as variable names.
5. Variable names are case-sensitive. (JavaScript is a case-sensitive language)
Global variables
Variables declared outside the method
Inside the method, there are no variables declared with the VAR keyword
Local variables
Inside the method, variables declared with Var

1.2. Data type

In ECMAScript, data types are also classified into basic types and reference types .
Base data type: Number, Boolean, String, Undefined, Null
Number: Integers and decimals (highest precision 17 decimal places), NaN, Infinity,-infinity
Note: 1. In addition to the 10 binary, it can also be represented by 8-and 16-binary literals, such as 070 for 56, and 0xA for 10.
2. Decimal is a floating-point type, if (a+b = = 0.3)//Do not do such a test, because the highest precision floating point value is 17 bits, but 0.300000000000000004.
Undefined: Represents a variable declaration but is not assigned a value.
Null: Represents an empty object reference (that is, the assignment is null)
Reference type: Object type (such as objects, arrays, REGEXP, Date ...)
Typeof operator
Values for base types and reference types
The base type is accessed by value, because the actual value saved in the variable can be manipulated
Reference types are accessed by reference.

Real Columns:                //Number type integer and decimal                                varA1 = 10 ; varA2 = 10.5 ; varA3 = NaN;//Not a number                vara4 = 1/0; Positive InfinityvarA5 = 070;//8 binary and 16 binary (0xA)                //alert (A4);                //alert (A5);                                           varA8 = parseint ("AAABBCC");//not a number                //alert (A8);                                varA9 = parseint ("12BBCC"); //alert (A9);                                                //undefined data type his value is only one: undefined represents a variable declaration, but is not assigned a value                varB1; //alert (B1);                                //Null empty value                varB2 =NULL ; //alert (B2);                                //String                varSTR1 = "I am the string 1"; varstr2 = ' I am the String 2 '; //Boolean                varFlag1 =false ; varFlag2 =true ; //Reference Data Type                vararr = [n/a];//Array Type                varDates =NewDate ();//Date Type                varobj = {};//Empty Object                                                //The typeof operator is used to determine the data type                                varA = 10 ; //number varb = 10.3 ;  //number                  varc =true ;  //boolean                  vard = ' ABCD ';  //string                  varE =NewDate (); //object varf =NaN; //number varg = [A]; //object varh =undefined; //undefined vari =NULL;//Indicates a reference to an empty object
                Alert (typeoftypeof is used to determine what type of object

Note I. First knowledge of Javascript

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.