JavaScript Learning Journey: the first stop.

Source: Internet
Author: User

JavaScript can output data in different ways:
    • Use the window.alert () pop- up warning box.
    • Use the document.write () method to write content to an HTML document.
    • Writes to an HTML element using InnerHTML .
    • Use Console.log () to write to the browser's console.
Data types in javascript:

Numbers (number)

Strings (String)

Arrays (Array)

Objects (object)

Functions (function)

In programming languages, variables are used to store data values.

JavaScript uses the keyword var to define the variable, using the equal sign to assign a value to the variable

var length = 16; Number is assigned a value by a numeric literal
var points = x * 10; Number is assigned by an expression literal
var lastName = "Johnson"; String literals are assigned a value by literal literals
var cars = ["Saab", "Volvo", "BMW"]; Array literals are assigned values
var person = {firstName: "John", LastName: "Doe"}; object is assigned a value by its literal number

JavaScript statements are commands that are sent to the browser.

The purpose of these commands is to tell the browser what to do.

Semicolon

Semicolons are used to separate JavaScript statements.

Usually we add semicolons at the end of each executable statement.

Another useful use of semicolons is to write multiple statements in one line.

JavaScript Code

JavaScript code is a sequence of javascript statements.

The browser executes each statement sequentially, in the order in which it was written.

JavaScript code block

JavaScript can be grouped together in batches.

The code block begins with an opening curly brace and ends with a closing curly brace.

The function of a code block is to execute a sequence of statements together.

JavaScript Statement identifiers

JavaScript statements typically begin with a statement identifier and execute the statement.

Statement identifiers are reserved keywords that cannot be used as variable names.

Statement Description
Break Used to jump out of a loop.
Catch Statement block that executes a catch statement block when a try statement block performs an error.
Continue Skips an iteration in the loop.
Do ... while Executes a block of statements that continues executing the statement block when the condition statement is true.
For When the conditional statement is true, the code block can be executed a specified number of times.
For ... in Used to iterate over an array or an object's properties (to iterate over a group or an object's properties).
function Define a function
If ... else Used to perform different actions based on different conditions.
Return Exit function
Switch Used to perform different actions based on different conditions.
Throw Throws (generates) an error.
Try Implements error handling and is used with catch.
Var Declares a variable.
While When the conditional statement is true, the statement block is executed.

JavaScript Learning Journey: the first stop.

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.