Getting the javascript js basic data types and data conversion 01

js data structure and the data base entry of the converter 01 javascript

        js composition (ECMAScript, BOM, the DOM)
        js the print statement:
        Data type
        variable
        Operators
        data type conversion
        js three special values in

the composition of the js (ECMAScript, BOM , the DOM)

①ECMAScript: ECMAScript is a standard that specifies the syntax types, statements, keywords, reserved child, operator, object. (Equivalent law);
②BOM (Browser Object Model): browser window to access and manipulate operations;
③DOM (Document Object Model): DOM entire page is mapped to a multi-node structure. HTML pages are composed of some type of nodes, which in turn contain different types of data;
JS print statement:



    ①alert () pop pop-up blocking program execution;
    ②document.write () page printed page, affect the layout, in some cases cover page;
    ③console.log (); printed to the console;
    ④prompt () print can enter dialogue popups (dialog box);
    ⑤confirm () pops up a pop-up box OK or cancel dialog;


data type

1 simple (primitive) data types
①string string character string in quotation marks ( "") are quoted character data package ;
②number digital
NaN is numeric type, represents not a number, not the calculation results
③Boolean Boolean to false to true
④undefind unassigned
⑤null empty
ES6 are new types:
⑥symbol

    complex (object) data types
    ①object objects wrapped with {}
    ②array array with [] wrapped
    ③function function

3. data type detection typeof
operation type return values are:
string, string
boolean, Boolean (to true / to false)
number, digital (including NaN, isNaN () is used to determine whether the data NaN3)
undefined, undefined
object, the object
function function
variables

created variables:
    statement: var,
    assignment operator: =
on variable naming Note:
    ① must begin with a letter or _ or $
    ② prefixes beginning with the letter is best to use the data type, can be more semantic
    ③ keywords and reserved words can not be used as variable names
            common keywords: typeof, var, break, continue , return, default , etc.

operators

1. The arithmetic operators
+ plus (+ sign when both sides, as long as the emergence of a character, then that character string splice (connection), the value on both sides, is the value +)
- Save (and implicitly adding character conversion)
* multiplication (and implicitly adding character conversion)
/ addition (addition and character will implicit conversion)
% remainder (and implicitly converted characters are added)

2. The relational operators
<less than
> greater than
<= Less than
> = Greater than or equal to
== equal (Note that a "=" is assigned)
=== strict equality (no implicit type conversion, not only when compared to a comparison value, but also comparison data types)

3. logical operators
|| or (that is, a true is true)
&& and (that is, there is a false, false)
! Non (inverted)

4. increment-decrement
n ++ increases after the first operation, each time plus one
after the first operation ++ n increases, plus one each
n-- reduced after the first operation decrements a
-n reduced after the first operation, each time a Save

The assignment operator
= assignment
+ = cumulative
- like Save =
* = multiplication
/ addition equals =
data type conversion

transfer numeric characters 1.
①parseInt () parse a string, returns an integer, from left to right detection encountered digital conversion, Caught stop numbers, the first one for non-digital converter stops outputting NaN, the decimal point will filter the content that is non-decimal number; the other band can be converted to decimal syntax: the parseInt (NUM, 2 /. 8/16)
②parseFloat ( ) parsing a string and returns a floating point number left to right ,, detection encountered digital conversion, digital conversion Caught encountered non-stop digital output NaN, can recognize the first dot, the second void;
③Math.round () converts strictly, to the nearest integer, not allow any non-numeric, there is the NaN3;
④number () conversion strictly, cast, the decimal point can be identified, does not allow any non-numeric, i.e., appears NaN3

2. digital-to-character
①num.tostring () direct conversion, corresponding to the value added to a quote, may be further converted into other decimal syntax: num.toString (2/8/16)
②num.toFixed () and toString consistent, n may be rounded decimal

3. implicit type conversion rules in the scene if (there is any type of final ture / false value of a Boolean):
① values: two comparison values, that is, as long as 0 ture does not appear;
② characters: two characters compared to non-empty as long (double quotes nothing, including spaces) is the ture;
③: Object are ture ;
④ array: array are ture;
⑤ functions: functions are ture;
⑥underfind, NaN, null: three appear are false;

4.isNaN
JS in three special value

NaN, underfind, null
------ ----------

Attach csdn blog address:
Copyright: This article is CSDN blogger ", presumptuous' original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/weixin_43752578/article/details/100144904

Guess you like

Origin www.cnblogs.com/zxlone/p/11518785.html