First day of JavaScript

Source: Internet
Author: User
Tags script tag

Learning content:

JavaScript official name ECMA script or ECMA-262

Short JS

1.js Embedding Method:

(a) JavaScript prefixes introduced into JS

1 <  href= "Javascript:alert (' Hello World ')">Hello</a  >

(b) Inline references

Use the script tag, which can be placed between the head or body tag, loading order head>body, because the HTML file is loaded from top to bottom

1 <Head>2     <Script>3 Alert ("This is the second method of introduction")4     </Script>5 </Head>

(c) External references

External reference JS file, similar to the external reference of CSS, can also be placed between the head tag or body tag

1 < Body > 2     <  src= "Jsd1.js"></script>4  </body>

2. Basic syntax

(a) The name of the variable: the first letter must be a letter (uppercase and lowercase), an underscore (_), or a dollar sign ($),

The remaining letters can be underlined, dollar signs, any letter or numeric characters

var x = B%log; Illegal Disclaimer:% not Available

Can't use keywords!

Keywords refer to words that have been defined by syntax as having special meanings, var = var; it's an illegal statement.

Variable declaration is case sensitive var x = 1 Not equal to var x = 1

(b) Declaring variables:

An implicit declaration such as x = 1
An explicit declaration such as var x = "Hello"

1 <script>2     x = 1;   implicitly declares 3     var x = "Hello";   Explicit Declaration 4 </script>
<script>    var  y;     // assign a value after declaring the variable first </script>
1 <script>2     var a = 1, b = 2, c = 3;   declare multiple variables at once 3 </script>

3. Variable Common data types

(a) numeric type: Contains integral and floating-point types
(b) String type: must be enclosed in single or double quotation marks.
(c) Boolean type: True False
(d) Undefined type: specifically used to determine a variable that has been created but has no initial value, such as Var x; alert (x);
(e) null type var x = null;
(f) Object type array, date, and so on

Ps:

= is the assignment = = Determines whether the two ends are equal, only considering that the value does not consider the data type for example: Var x=2 var y= "2" x==y true
= = = Consider data value and type X===y false

In a strict sense, an empty type is not equal to an undefined type such as Var x; var y = null; X===y false

Null type is assigned a null value, undefined type not assigned value

Single-line comment//Multiline comment/**/

1<script>2     varb =NULL;//Empty Type3     varA = 10;//Integral type4     varc = 1.25;//floating Point Type5     vard = "Hello";//String Type6     varE =true;//Boolean type7     varF//type not defined8     varg = new Array (+/-);//Array Object Type9     varh = 3e2;//The method of integral type scientific countingTen</script>

2018/02/23

First day of JavaScript

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.