Basic learning of JavaScript (i)

Source: Internet
Author: User

How JavaScript is introduced
{#1 write directly #}     <script>        alert (' Hello Yuan ')    </script>{#2 import File #}    <script Src= "Hello.js" ></script>
2.1 Variables

1 You do not declare variable types when declaring variables. All use the var keyword;

var A;

2 A row can declare multiple variables. And can be of different types.

var name= "Yuan", age=20, job= "lecturer";

3 (understand) You can declare variables without var. if you don't use Var then it is a global variable.

4 variable name, first character can only be letter, underscore, $ dollar symbol three select one, and case-sensitive, x and X are two variables

5 variables should also adhere to one of the following well-known naming conventions:

The first letter of the Camel notation is lowercase, and the next letters begin with uppercase characters. For example:var mytestvalue = 0, Mysecondvalue = "Hi" = 0, Mysecondvalue = "Hi" = 0, SMYSECONDV alue = "HI";

Attention:

    function func1 () {                var a = 123;        b=456    }    func1 ();     //     alert (a); //     alert (b); // Not recommended

1 the end of each line can be without a semicolon. No semicolon will end with a newline character as each line

a=1;b=2; a=1 b=2;------ Error A=1b=2// recommended a=1; b=2; {a=1 ; b=2;     // recommended Add tab    A=1;    b=2;}
View Code

2 Comments Support multiline comments and single-line comments./* */ /

3 using {} to encapsulate a block of code

2.3 Constants and identifiers

Constants : data values that appear directly in the program

identifiers :

    1. Consists of letters, numbers, underscores (_), Dollar signs ($) that do not begin with a number
    2. a name commonly used to denote functions, variables, etc.
    3. For example: _ABC, $ABC, abc,abc123 is an identifier, and 1ABC is not
    4. Words that represent a particular meaning in the JavaScript language are called reserved words and do not allow programs to be redefined as identifiers




Basic learning of JavaScript (i)

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.