Front-End notes 14 JavaScript syntax

Source: Internet
Author: User
Tags bitwise string indexof

Coercion type conversion functiontoString (): Converts Boolean, numeric, and so on to stringparseint (): Converts a String, Boolean value, to an integerparsefloat (): Converts a String, Boolean, and so on to a floating-point numberThere is no block scope in the  javascript, the local variable in the output function overrides the global variable, even if the scope of the local function still works in defining the variable, if VAR is used to force the definition of a new variable, If there is no Var then the system will take precedence over whether the variable exists in the current context, and if it does not, it will redefine a new variable   science and technology law means that the value:<num1>e<num2> represents the num2 of the num1*10; The constants of the =500,1.23e-3=0.00123number class correspond to the special values Number.MAX_VALUE: The maximum allowable value of a numeric variable number.min_value: The minimum allowable value of a numeric variable number.positive_ Infinity:infinity, positive infinity number.negative_infinity:-infinity, negative infinity Number.NaN:NaN, non-number   string type, The string class has the following basic methods and properties string (): Constructs a string charat (num): Gets the string num characters, starting from 0 number charCodeAt (num): Returns the Unicode value for the number of num characters in a string length: Returns the string toUpperCase (): All letters become uppercase toLowerCase (): All letters become lowercase fromcharcode (): Converts a Unicode value to a string indexof (SearchString [, StartIndex]): Searches for the location where the target string searchstring appears, without searching for the preceding StartIndex characters LastIndexOf ( SearchString [, StartIndex]): Search for the last occurrence of the target string searchstring, do not search the first StartIndex characters, return -1substring (start [, end]): Starting at start, intercepts the character slice (start [, end]) at end (not included): Starts at start, intercepts the character at end (not included), but can use negative index values, the rightmost index is -1match (), Search (): Search for a target string using regular Expressions Concat (): Add multiple strings to a string split (): Separates a string into multiple strings, you can specify a delimiter replace (): Replaces a substring in a string with a specific string instead of  undefinedIndicates that a variable does not exist null to indicate that a variable value is empty   regular expression: More characters supported, self-lookup   composite type: A data body consisting of multiple base data types Object: Object class array: Array class function: Functions class Date: Date class Error: Wrong class Math: Mathematical class, contains quite a number of execution mathematical methods, commonly used Pow,sqrt,randomnumber: Numeric class String: String class   Array of three ways to express: var a = [3, 5, 23];var b = [];var c = new Array ();  bitwise operator: &AMP;: Bitwise AND |: Bitwise OR ~: Bitwise NON ^: bitwise XOR or &LT;&LT;: Left shift operator >>: Right shift operator >>>: Unsigned right-shift operator   comparison operator:: Greater than >=: greater than or equal to <: Less than <= less than equals! =: Not equal to, just numeric inequality, ignoring the comparison of data types = =: equals!==: Strictly not Equal, if the two values are not equal or the data type is different, Returns true===: Strictly equal To, must be two values equal and the data type is the same before returning the true  three mesh operator: (expression)? if-true-statement:if-false-statement;  comma operator: Multiple expressions are queued together, and the entire expression returns the value of the rightmost expression, such as a = (b=5,c=6,d=56), then a=56  void operator: Forcibly specifying an expression does not return a value  typeof (a) Operator: Returns the data type of a, which can have the following undefined values: Undefined;null Value: Object; Boolean value: Boolean; Numeric value: number; string value: String; object: objects; function: function;instanceof operator: Determines whether a variable is an instance of a specified class, such as a instanceof array  Statement BLOCK: Using multiple statements contained in curly braces, a statement block is a whole body of execution, similar to a separate statement empty statement: ";" an exception-throwing statement is often thrown in the loop body: throw new Error (errorstring); Exception snap statement: When the program has an exception, You can use catch to catch exceptionssyntax--try{statements} catch (e) {statements} finally{statements}executes a try statement first, and if an error occurs inside a try, it automatically jumps to the catch block execution, and finally the block always gets the chance to execute.With statement: For example, if with (document) in statements, you can omit the write document format with (object) {statements} Process Control: 1, if statement ①if (logic expression) {statement.} ②if (logic expression) {statement:} else {statement ...} ③if (logic expression) {statement:} else if (logic statement) {statement:} else {statement ...} 2. Switch statement switch (expression) {Case condition 1:statement ...;Case condition 2:statement ...;... ..Case condition n:statement ...;default:statement;}3, while statement: First judge, then execute while (expression) {statement ...}; If expression is true, the expression is executed, otherwise the expression4, do, and do statements are not executed: Execute first, then Judge Do{statement} while (expression) 5, the For Loop for ( initialization; Test Condition;iteration statement) {statement ...} 6. For in traversal for (index in object) {statement}7, break ends the entire loop, continue ends the loop   function: 1, defines the named function functionname ( parameter-list) {statement.} 2, define the anonymous function, this in the last side need to add a semicolon function (parameter list) {statement ...}; 3, using function class anonymous functions var (' name ', "Document.writeln (function defined Functions <br> ')" + "Document.writeln (' Hello ' +name) ;”); 4, recursive function 5, local variables and local functions, local functions only when the global function is called to run 6, if the direct definition of a function is not attached to the object, it will be automatically appended to the Window object   Instance properties and class properties of functions Local variables: variable instance properties defined in normal way: variables decorated with the This prefix in a function, property values for each instance may not be homogeneous: variables decorated with function name prefixes in functions   three ways to call functions 1, call the function 2 directly () method call function; caller. function (parameter 1, parameter 2 ...) ) = function. Call (caller, parameter 1, parameter 2 ...) ) 3, call the function with the Apply () method, similar to calling (), but calls need to be listed in parentheses in detail each parameter, apply can be in parentheses with argument to represent all parameters   can be extended by the prototype property to the original function, Implement pseudo-inheritance   use the form of Key:value to create objects using JSON syntax, followed by a comma after the kv pair, but no comma after the last one. JSON can also be used to create arrays, such as ①var a =new array (' AAAA ', ' NoNoNo '); ②var b = [' AAAA ', ' Nononono '];arr=[value1,value2 ...];

Front-end note 14 JavaScript syntax detailed

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.