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)