Js01-javascript syntax standards and data types

Source: Internet
Author: User

Grammar Rules

(1) JavaScript is not sensitive to line, indent, and space.

Note: Each statement ends with a semicolon, although the semicolon is not mandatory, but for the program to be compressed in the future, if not semicolon, after compression will not run.

(2) All the symbols are in English. such as parentheses , quotation marks, semicolons.

(3) JavaScript comments:

// single-line comment
/* This is a multi-line comment */

Note: In sublime, the shortcut key for a single-line comment is ctrl+/ that the shortcut key for a multiline comment is ctrl+shift+/ .

variable naming rules:

Strictly case-sensitive
-names can appear with letters, numbers, underscores, $, but not numbers, or pure numbers
-Cannot contain keywords and reserved words.
Keyword: var number
In addition to the keyword top name try not to use it.
-Recommended Hump nomenclature: when there are several meaningful words that make up the name, the first letter is lowercase and the remaining words are written in the first letter.
-Hungarian name: It is based on the first character of the data type Word as a prefix

Data type:

Data types include: basic data types and reference data types

The base data type refers to simple data segments, which refer to objects that have multiple values.

1. Basic data types1.1 Number
var a = 123; // typeof Check what the current variable is data type console.log (typeof  a)// special case var a1 = 5/0; Console.log (typeof//Infinity infinitely large. Number Type
1.2 String
var str  = ' 123 'console.log (typeof str)
1.3 Boolean
var false ; Console.log (typeof  B1) // in JS, all data types are converted to the Boolean type. 0,nan,underfined and False are false, others are true
1.4 Null
var null; // empty objects. Object Console.log (C1) // NULL is an object
1.5 undefined
var D1; // indicates that the variable is undefined console.log (typeof D1)

Js01-javascript syntax standards and data types

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.