JS Basic Learning Notes (i)

Source: Internet
Author: User

JavaScript basics
1. Component: Consists of ECMAScript(translation, core, interpreter),DOM(ability to manipulate HTML),BOM(browser window), three parts.

Compatibility followed by [1. There are few compatibility issues, 2. Some operations are incompatible, 3. completely incompatible;]


2. Variable type: Numeric type (number) (string), Array (Arry), Boolean (Boolean),object (function), undefined (undefined) ; NaN (not present);

Type method for testing variables: alert (typeof)

Give me a chestnut:

var str= ' 1 '; if (typeof (Str) = = ' string ') {alert ("This is a variable of type string")); };

3. Type conversion: When converting a string, if the string does not contain a number, the program pops up nan! (Display type conversions, implicit type conversions)

One. Display Type conversions

①parseint: Converting a String type to a numeric type

Attributes (starting from left to right to detect numbers, the program automatically jumps out when a non-numeric type is encountered in the program; parseint can only be converted to integers)

var a=1.2; Alert (parseint (a)); Pop up 1

We now need a property that can completely convert the decimal!

②parsefload:hi to convert the decimals completely.

var b=1.2; Alert (Parsefload (b)); Pop up 1.2

Two. implicit conversion type

①==

Feature (the first step is to convert the variable types on both sides to the same type before comparing them)

var a=1;    var b= ' 1 ';    alert (A==B); The bounce is true.

②===

Attribute (the type of the variable on both sides of the conversion is started to compare)

var a=1;    var b= ' 1 ';    alert (A===B); The bounce is false.

4. NaN

Concept: nan is a numeric type, and any number and Nan are equal to Nan when added.

nan = =nan is unequal, only isNaN () can judge that Nan is equal to itself

Chestnuts:

is Small applications of Nan

JS Basic Learning Notes (i)

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.