Nodejs Basic Syntax node. JS's data Type node. JS's logic determines the various loops of node. js using functions to see if and JS have any difference using node's REPL mode REPL (read-eval-print l OOP), which is input-evaluation-output loops. Number (Numeric) Boolean (Boolean) object (object) array (array) string (string) Undefined null (NULL)
The undefined type has only one value, that is, a special undefined, which is undefined when you use VAR to declare a variable without initializing it. Logically, it represents a null pointer (the reference object points to its actual value) so this is also the reason why using the typeof operator to detect null would return an object: If you define certain variables, you might want to use Var cart=null to store object types in the future; So that we can directly check null and know that the object is saved from other objects. Note: Undefined is a presentation derived from a null type although they are out of the same door, their usefulness is completely different, for example, In any case we don't have to set a value to undefined, but we will set the variable to NULL as much as possible when we set a variable to be used to save the object in the future.
The
Boolean type is used for more than one type, with only two values, true and false, used to judge that he and 0 and 1 are not the same thing, (although we are so realistic when we convert the value to number type) Note Case sensitivity We can also play this way: var message= "Hello World"; var messageboolean=boolean (message);--transformation function string non-empty string-true empty string--false number any non-0 value--true 0-false Sometimes we can do the verification case to see if the user enters
Number is commonly used----2 8 10 16 The most basic keynote literal format is the decimal digit var num=100; In addition to decimal accidents can also represent more binary value var num=070 ----first digit must be 0//8 value first bit 0 079---invalid octal var num=0xa;/16 0-15 A B c D E F var num=0x1f; Tofiexd (); Floating-point type--decimal var num=1.1/0.1/.1---it is not recommended to save floating-point type memory space is twice times the integer type, so if there is no value after the decimal point is automatically converted to an integer type save for those large or small values, you can use E to denote ( Scientific notation), stating that the value is equal to the value in front of e-clothing 10 exponential power var floatnum=3.125e7--3.125x10 floating-point type the highest precision is 17-bit mice, but in the calculation of the accuracy is far less than the integer such as 0.1+0.2=? 0.05+0.25? So don't test a specific floating-point value This is due to the IEEE754 floating-point value calculation of the maximum minimum range of common cases the conclusion does not represent all the range of values, then what if his range of values is exceeded? When this value is exceeded, it is automatically converted to the Infinity (infinite range) case, and the test is infinite when a value is infinite, it will not be able to continue to participate in the next calculation, so infinity is not able to participate in the calculation of the value, To determine if a value is infinite we can use the Isfinite (method)
Nan Non-numeric not a number operation this value is used to indicate that an operand that would have returned a numeric value does not return a numeric operation, such as any number divided by 0, it does not want to wait with any value, including itself for this feature presented isNaN () This method case NaN ten "" Hell O "true assignment conversion three more important function conversions Numeric number () parseint ()--determines the value to be converted to an integer parsefloat () numbers function conversion rule true-1 false-0 null--0 Undefin Ed--nan if it's a string if it's just a numeric direct conversion if there are decimal points, convert to floating point if there is a 16 binary, then to the corresponding decimal if the string is empty, then the conversion to 0 does not include the above is converted to Nan because the number conversion process is responsible for, it is recommended to use par Seint () solves the troublesome number of mixed strings and numbers to be in front
The statement if Do-while while the for//for-in//array details The Swith branch-the equivalent judgment function function, which is the top-level entity in a procedural language such as C, and in object-oriented languages such as java/c++, is wrapped by the object. A method commonly called an object. In JavaScript, the function itself is no different from any other built-in object, that is, the function itself is also the method of the object JavaScript creation function 1:function ([parameters]) {Functionbody} 2 : Var fun=function () {}--assigns a variable name to an anonymous function in a way that defines it
function parameters in JavaScript, the parameters of the function is interesting, for example, you can pass any number of parameters to a function, even if the function declaration does not have a formal parameter case-testing whether the user passed in parameters or not if the parameter is not passed, if the parameters are passed in, But no parameters are defined, use the arguments[subscript] to use the parameter
The concept of scope is embodied in almost all mainstream languages, and in JavaScript it has its peculiarities: variable scopes in JavaScript are valid within the function body, without block scopes, and functions have no overloaded concept, only the concept of overrides
node. JS Basic Syntax