Chapter 11th Subset and extension of JavaScript

Source: Internet
Author: User

11.1 A subset of JavaScript

  11.1.1 Essence

  Security of 11.1.2 subsets

11.2 Constants and local variables

<script type= "Text/javascript" >//keyword let has 4 ways to use    //can be declared as a variable, as with Var    //in the For or for/in loop, as a substitute for Var    //defines a new variable in a statement block and displays the scope that specifies it    //defines a variable within the scope of an expression that is only available in an expression    functionoddsum (n) { let total= 0, result = [];  for(Let x = 1; x <= n;x++) {Let odd= 2 * x-1; Total+=Odd;        Result.push (total); }        returnresult; }    //Console.log (total);//referencerrrorConsole.log (Oddsum (5));</script>
View Code

11.3 Deconstruction Assignment

<script type= "Text/javascript" >    // deconstructed Assignment (destructuring Assignment)let    [x, y] = [+];  // Let x=1,y=2    [x, Y] = [× + 1,y + 1];  // x = x + 1,y = y + 1    [x, Y] = [y,x];    Console.log ([x, y]); </script>
View Code

11.4 iterations

  11.4.1 For/each Cycle

<script type= "Text/javascript" >    = {one:1,two:2,three:3}    for in o) {        console.log (p);    }     // For each (let V in O) {    //     Console.log (v);    // }</script>
View Code

  11.4.2 iterators

<script type= "Text/javascript" >    Function  counter (start) {        = math.round (start);         returnfunctionreturn nextvalue++;}};    }     = Counter (+);     = Serialnumbergenerator.next ();     = Serialnumbergenerator.next (); </script>
View Code

  11.4.3 Generator

<script type= "Text/javascript" >    // Generator is an object that represents the current execution state of the generator function /    *     function Range (Min,max) {for        (Let i = Math.ceil (min); I <= max;i++) {            yield i;        }    }    for (Let N in range (3,8)) {        console.log (n);    }     */</script>
View Code

  11.4.4 Array Derivation

<script type= "Text/javascript" >//JavaScript1.7    //array derivation is a technique for initializing array elements using another array or an iterative object .    //Let evensquares = [x*x for (x in range (0,10)) if (x 2 = = = 0)];    //Let evensquares = [];    //For (x in range (0,10)) {    //if (x% 2 = = = 0) {    //Evensquares.push (x*x);    //    }    //}    //[expression for (variable in object) if (condition)]</script>
View Code

  11.4.5-Generator expression

<script type= "Text/javascript" >    /leth = (f (x) for (x in G));    // Let lines = eachline (text);    // Let trimmed = (L.trim () for (L in lines));    // Let nonblank = (L-in trimmed) if (l.length > 0 && l[0]! = ' # ')); </script>
View Code

11.5 Shorthand for functions

<script type= "Text/javascript" >    // for simple functions, JavaScript1.8 introduces a shorthand form: expression closure     functionfunctiontruefunctionfalse; </script>
View Code

11.6 Multiple Catch clauses

<script type= "Text/javascript" >/    *    try {        throw 1;    }    catch (E if e instanceof referenceerror) {    }    catch (e if E = = = "Quit") {    }    catch (e if typeof e = = = "str ing ") {    }    catch (e) {    }    finally {    }    */</script>
View Code

11.7 E4x:ecmascript for XML

Chapter 11th Subset and extension of JavaScript

Related Article

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.