Iii. type, value, variable the first part--javascript language core

Source: Internet
Author: User
Tags time and date

Value: The operation of a computer program requires the operation of the value (values).

Data type: A type that can be represented and manipulated is called a data type.

Variable: When the program needs to save the value for future use, it assigns it to a variable.

A variable is a worthwhile symbolic name that can be obtained by name for a worthwhile reference.

JavaScript variables are of no type and can be assigned any type of value. Use Var to declare a variable.

JavaScript takes a lexical scope. A variable declared within a function has a function scope and is visible only inside the function. A variable that is not declared within any function is called a global variable and is visible anywhere in the JavaScript program.

The data types of JavaScript are divided into two categories: the original type and the object type.

Original type: The original type in JavaScript contains numbers, strings, and Boolean values. JavaScript also contains 2 special original values null, undefined

Object type: JavaScript is an object in addition to numbers, strings, Boolean values, NULL, and undefined.

An object is a collection of attributes, each of which is made up of "name-value pairs" (values can be original or object). There is a special object-------the global object.

Arrays: JavaScript also defines a special object-----------array that represents a numbered, ordered collection. (Having different behavioral characteristics from ordinary objects)

Function: JavaScript also defines another special object-----------function. A function is an object that has executable code associated with it, runs executable code by calling a function, and returns the result of the operation. (also having different behavioral characteristics from ordinary objects)

Constructor: If a function is used to initialize (using the new operator) a new object, called a constructor. Each constructor defines a class object.

Class object: A collection of objects initialized by constructors. A class can be thought of as a subtype of an object type. In addition to array classes (array) and function classes (functions), the JavaScript language core defines three other useful classes. A date class (date) Defines an object that represents a date. A regular class (REGEXP) defines an object that represents a regular expression. Error classes (Errors) define which objects represent run-time and grammatical errors in JavaScript programs. You can define the classes that you want by defining your own constructors.

3.1 Numbers

Unlike other languages, JavaScript does not differentiate between integer values and floating-point values. All numbers in JavaScript are represented by floating-point numbers.

3.1.1 Integer Direct Quantity

In JavaScript, a numeric sequence is used to represent a decimal integer.

JAVASCIRPT also supports the direct amount of 16. Begins with 0 x. such as 0xFF

JavaScript also supports the direct amount of the 8 binary. Starts with 0, but some implementations are not supported. such as 0377

3.1.2 Floating-point type Direct quantity

Can contain a decimal point.

Arithmetic operations in the 3.1.3javaScript

Support basic operations: + 、-、 *,/,%

In addition to basic operations, JavaScript supports more complex operations, which are implemented through functions and constants defined by the properties of the Math object.

JavaScript does not complain when overflow, underflow, and 0 are removed.

Infinity and Nan:javascript predefined global variables ifinity and Nan represent positive infinity and non-numeric.

Overflow: Returns infinity (infinity) When the result of an operation is infinitely large, exceeding the upper limit of JavaScript.

Underflow: When the result of an operation is infinitely close to 0, the minimum value that JavaScript can represent is smaller, and JavaScript returns 0. When a negative number overflows, JavaScript returns negative 0.

by 0 except return positive infinity infinity or negative infinity-infinity.

0 divided by 0, meaningless, return Nan. Represents a non-numeric number.

Returns a Nan when it is not numeric and cannot be converted to a number.

Nan and any value are not relative, including itself. You can use isNaN () to determine if it is Nan.

Isfinite (), returns True when the parameter is not nan,infinity,-infinity.

The negative 0 value is equal to the positive zero value. These 2 values are almost exactly the same, except as divisor.

The positive infinity and the negative infinity vary.

3.1.4 binary floating-point numbers and rounding errors

Binary is not an exact representation of 0.1. Currency calculations are computed using large integers.

3.1.5 Date and time

The date () constructor to create a time and date object.

3.2 Text

A string is an immutable ordered sequence consisting of 16-bit values.

JavaScript represents text through strings.

3.2.2 Escape character

\ Escape Symbol

3.2.4 Pattern Matching

The object that the REGEXP () constructor uses to create a text-matching pattern. These patterns become regular expressions. Both string and RegExp define a function that uses regular expressions to match patterns and find and replace them.

3.3 Boolean values

Boolean value is only 2 values, true and False

Any JavaScript value can be converted to a Boolean value. The following values are converted to false:undefined, NULL, 0, -0, NaN, ""

All other values, including all objects (arrays), will be converted to true.

Boolean operator: &&,| |,!

3.4null and undifined

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.