1、ES6 ES6 i About the Tutorial ECMAScript (ES) is a scripting language specification standardized by ECMAScript International. It is used by applications to enable client-side scripting. Languages like JavaScript, Jscript and ActionScript are governed by this specification. This tutorial introduces yo
2、u to ES6 implementation in JavaScript. Audience This tutorial has been prepared for JavaScript developers who are keen on knowing the difference between ECMAScript 5 and ECMAScript 6. It is useful for those who want to learn the latest developments in the language and implement the same in JavaScrip
3、t. Prerequisites You need to have a basic understanding of JavaScript to make the most of this tutorial. Disclaimer & Copyright Copyright 2016 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-b
4、ook is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may
5、contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at . ES6 ii Table of Contents
6、 About the Tutorial . i Audience . i Prerequisites . i Disclaimer & Copyright . i Table of Contents . ii 1. ES6 OVERVIEW . 1 JavaScript . 1 2. ES6 ENVIRONMENT . 2 Local Environment Setup. 2 Installation on Windows . 2 Installation on Mac OS X . 3 Installation on Linux . 4 Integrated Development Envi
7、ronment (IDE) Support . 4 Visual Studio Code . 4 Brackets . 7 3. ES6 SYNTAX . 10 Whitespace and Line Breaks . 11 Comments in JavaScript . 11 Your First JavaScript Code . 12 Executing the Code . 12 Node.js and JS/ES6 . 13 The Strict Mode . 13 ES6 and Hoisting . 14 ES6 iii 4. ES6 VARIABLES . 15 Type S
8、yntax . 15 JavaScript and Dynamic Typing . 16 JavaScriptVariable Scope . 16 The Let and Block Scope . 17 The const . 18 ES6 and Variable Hoisting . 18 5. ES6 OPERATORS . 20 Arithmetic Operators . 20 Relational Operators . 22 Logical Operators . 23 Bitwise Operators . 24 Assignment Operators. 26 Misc
9、ellaneous Operators . 27 Type Operators . 29 6. ES6 DECISION MAKING . 30 The if Statement. 30 The ifelse Statement . 32 The elseif Ladder . 33 The switchcase Statement . 34 7. ES6 LOOPS . 38 Definite Loop. 38 Indefinite Loop . 41 The Loop Control Statements . 44 Using Labels to Control the Flow . 45
10、 ES6 iv 8. ES6 FUNCTIONS . 49 Classification of Functions . 49 Rest Parameters . 52 Anonymous Function . 52 The Function Constructor . 53 Recursion and JavaScript Functions . 54 Lambda Functions . 55 Function Expression and Function Declaration . 56 Function Hoisting . 57 Immediately Invoked Functio
11、n Expression . 57 Generator Functions . 58 9. ES6 EVENTS . 61 Event Handlers . 61 onclick Event Type . 61 onsubmitEvent Type . 62 onmouseover and onmouseout . 63 HTML 5 Standard Events . 63 10. ES6 COOKIES . 70 How It Works?. 70 Storing Cookies . 70 Reading Cookies . 72 Setting Cookies Expiry Date .
12、 73 Deleting a Cookie . 74 11. ES6 PAGE REDIRECT . 76 JavaScript Page Redirection . 76 Redirection and Search Engine Optimization . 77 ES6 v 12. ES6 DIALOG BOXES . 79 Alert Dialog Box . 79 Confirmation Dialog Box . 80 Prompt Dialog Box . 81 13. ES6 VOID KEYWORD . 83 Void and Immediately Invoked Func
13、tion Expressions . 83 Void and JavaScript URIs . 83 14. ES6 PAGE PRINTING . 85 15. ES6 OBJECTS . 86 Object Initializers . 86 The Object() Constructor . 87 Constructor Function . 89 The Object.create Method . 91 The Object.assign() Function . 91 Deleting Properties . 93 Comparing Objects . 93 Object De-structuring . 94 16. ES6 NUMBER . 95