Introduction of JS Basics, annotations, variables, data types, and output syntax

Source: Internet
Author: User

Introduced:

Single, double line comments:

The output syntax of JS
Pop-up Window form alert ();

alert (123);

The effect is as follows:

The prompt () method is used to display a dialog box that prompts the user for input

Prompt (' Please enter name ');

The effect is as follows:



document.write () print in an HTML document

document.write (123);//Can be displayed directly in the document

The effect is as follows:

Console output: Console.log (); General as debug output statement

Console.log (123); Control Desk

The effect is as follows:

Variable:

Note the naming conventions:

JS inside: Letters, numbers, underscores, $ symbols, such as 4 components, the number can not be the beginning of the name of the content.
Hump method naming

Assignment value:

var i=0;
I=1;
alert (i);

The effect is as follows:

Data type:

Number

var I=1;
Alert (typeof (i));

The effect is as follows:

Character:

var i= "abc";
Alert (typeof (i));

The effect is as follows:

To determine the Boolean:

var i=true; False
Alert (typeof (i));

The effect is as follows:

No objects selected:

var i=0;
Alert (typeof (a));

The effect is as follows:

Array:

var obj=["AA", "BB", "CC"];
Alert (typeof (obj));

The effect is as follows:

Introduction to

JS basics, annotations, variables, data types, and output syntax

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.