JavaScript Basics (i)

Source: Internet
Author: User

The composition of javascript:


BOM: Browser Object model

DOM: Document Object Model

Syntax for javascript:

JavaScript is a weakly typed language with no explicit data type, and when declaring a variable, you do not need to specify the type of the variable.

The declaration of a variable must use the keyword var.


var is a valid variable name.

Eg:var num=10 var x,y,z=1 x=10 (can not write Var direct declaration)

Data types for javascript:

Undefined (undefined type)

Null (NULL type)

Number (numeric type) (including integer and floating-point values)

String (String type)(enclosed in single or double quotes)

Boolean (Boolean type)(the return value is True or false)


Specific data types for detecting variables in javascript: using the keyword typeof

Syntax: typeof (variable or value)

If the variable is a null type, or if the variable is a reference type (such as an object, function, array), the result of the type object is returned

syntax for creating arrays in JavaScript:

var array name =new array (size);

The size represents the number of elements in the array.

When accessing an array element, it is in the form of: array name [subscript]; Subscript starting from 0

Common properties and methods for arrays:

Property: Length Sets or returns the number of elements in the array


Join () adds a delimiter to split the elements in an array

Sort () sorts the array.

Push () adds one or more elements to the end of the array and returns the new length.

JavaScript Basics (i)

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: 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.