Preview ES6 Tutorial (PDF Version)

Total Page:16

File Type:pdf, Size:1020Kb

Preview ES6 Tutorial (PDF Version) ES6 ES6 About the Tutorial European Computer Manufacturers Association (ECMAScript) or (ES) is a standard for scripting languages like JavaScript, ActionScript and JScript. It was initially created to standardize JavaScript, which is the most popular implementation of ECMAScript. This tutorial adopts a simple and practical approach through JavaScript to describe the new features in ECMAScript 2015 (ES6), ECMAScript 2016 (ES7), ECMAScript 2017(ES8) and ECMAScript 2018 (ES9). Audience This tutorial is designed for the stemplate oftware programmers who have already worked with JavaScript and wishes to gain in-depth knowledge about the ECMAScript. The tutorial will give you enough understanding on the functionalities of ECMAScript and also about ES6, ES7, ES8 and ES9. Prerequisites An understanding of JavaScript programming concepts is necessary to gain maximum knowledge from this tutorial. Disclaimer & Copyright Copyright 2019 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-book 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 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 [email protected]. i ES6 Table of Contents About the Tutorial .................................................................................................................................... i Audience .................................................................................................................................................. i Prerequisites ............................................................................................................................................ i Disclaimer & Copyright ............................................................................................................................. i Table of Contents .................................................................................................................................... ii 1. ES6 − OVERVIEW ................................................................................................................. 1 JavaScript ................................................................................................................................................ 1 ECMAScript Versions ............................................................................................................................... 1 2. ES6 − ENVIRONMENT .......................................................................................................... 3 Local Environment Setup......................................................................................................................... 3 Installation on Windows ......................................................................................................................... 3 Installation on Mac OS X ......................................................................................................................... 4 Installation on Linux ................................................................................................................................ 5 Integrated Development Environment (IDE) Support .............................................................................. 5 Visual Studio Code .................................................................................................................................. 5 Brackets .................................................................................................................................................. 8 3. ES6 − SYNTAX .................................................................................................................... 11 Whitespace and Line Breaks .................................................................................................................. 12 Comments in JavaScript ........................................................................................................................ 12 Your First JavaScript Code ..................................................................................................................... 13 Executing the Code ................................................................................................................................ 13 Node.js and JS/ES6 ................................................................................................................................ 14 The Strict Mode ..................................................................................................................................... 14 ES6 and Hoisting .................................................................................................................................... 15 ii ES6 4. ES6 − VARIABLES ............................................................................................................... 16 Type Syntax ........................................................................................................................................... 16 JavaScript and Dynamic Typing ............................................................................................................. 17 JavaScriptVariable Scope ....................................................................................................................... 17 The Let and Block Scope ........................................................................................................................ 18 let and block level safety ....................................................................................................................... 19 let and multiple blocks .......................................................................................................................... 19 The const ............................................................................................................................................... 20 Constants are Immutable ...................................................................................................................... 21 const and arrays .................................................................................................................................... 21 The var keyword ................................................................................................................................... 22 var and hoisting .................................................................................................................................... 22 var and block scope ............................................................................................................................... 23 var and block level safety ...................................................................................................................... 23 5. ES6 − OPERATORS ............................................................................................................. 25 Arithmetic Operators ............................................................................................................................ 25 Relational Operators ............................................................................................................................. 27 Logical Operators .................................................................................................................................. 28 Bitwise Operators ................................................................................................................................. 29 Assignment Operators........................................................................................................................... 31 Miscellaneous Operators ...................................................................................................................... 32 6. ES6 − DECISION MAKING ................................................................................................... 37 The if Statement.................................................................................................................................... 37 The if…else Statement ........................................................................................................................... 39 The else…if Ladder ................................................................................................................................ 40 The switch…case Statement .................................................................................................................. 41 iii ES6 7. ES6 − LOOPS ...................................................................................................................... 45 Definite Loop......................................................................................................................................... 45 Indefinite Loop ...................................................................................................................................... 48 The Loop Control
Recommended publications
  • Javascript and the DOM
    Javascript and the DOM 1 Introduzione alla programmazione web – Marco Ronchetti 2020 – Università di Trento The web architecture with smart browser The web programmer also writes Programs which run on the browser. Which language? Javascript! HTTP Get + params File System Smart browser Server httpd Cgi-bin Internet Query SQL Client process DB Data Evolution 3: execute code also on client! (How ?) Javascript and the DOM 1- Adding dynamic behaviour to HTML 3 Introduzione alla programmazione web – Marco Ronchetti 2020 – Università di Trento Example 1: onmouseover, onmouseout <!DOCTYPE html> <html> <head> <title>Dynamic behaviour</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div onmouseover="this.style.color = 'red'" onmouseout="this.style.color = 'green'"> I can change my colour!</div> </body> </html> JAVASCRIPT The dynamic behaviour is on the client side! (The file can be loaded locally) <body> <div Example 2: onmouseover, onmouseout onmouseover="this.style.background='orange'; this.style.color = 'blue';" onmouseout=" this.innerText='and my text and position too!'; this.style.position='absolute'; this.style.left='100px’; this.style.top='150px'; this.style.borderStyle='ridge'; this.style.borderColor='blue'; this.style.fontSize='24pt';"> I can change my colour... </div> </body > JavaScript is event-based UiEvents: These event objects iherits the properties of the UiEvent: • The FocusEvent • The InputEvent • The KeyboardEvent • The MouseEvent • The TouchEvent • The WheelEvent See https://www.w3schools.com/jsref/obj_uievent.asp Test and Gym JAVASCRIPT HTML HEAD HTML BODY CSS https://www.jdoodle.com/html-css-javascript-online-editor/ Javascript and the DOM 2- Introduction to the language 8 Introduzione alla programmazione web – Marco Ronchetti 2020 – Università di Trento JavaScript History • JavaScript was born as Mocha, then “LiveScript” at the beginning of the 94’s.
    [Show full text]
  • MSD FATFS Users Guide
    Freescale MSD FATFS Users Guide Document Number: MSDFATFSUG Rev. 0 02/2011 How to Reach Us: Home Page: www.freescale.com E-mail: [email protected] USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 +1-800-521-6274 or +1-480-768-2130 [email protected] Europe, Middle East, and Africa: Information in this document is provided solely to enable system and Freescale Halbleiter Deutschland GmbH software implementers to use Freescale Semiconductor products. There are Technical Information Center no express or implied copyright licenses granted hereunder to design or Schatzbogen 7 fabricate any integrated circuits or integrated circuits based on the 81829 Muenchen, Germany information in this document. +44 1296 380 456 (English) +46 8 52200080 (English) Freescale Semiconductor reserves the right to make changes without further +49 89 92103 559 (German) notice to any products herein. Freescale Semiconductor makes no warranty, +33 1 69 35 48 48 (French) representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability [email protected] arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or Japan: incidental damages. “Typical” parameters that may be provided in Freescale Freescale Semiconductor Japan Ltd. Semiconductor data sheets and/or specifications can and do vary in different Headquarters applications and actual performance may vary over time. All operating ARCO Tower 15F parameters, including “Typicals”, must be validated for each customer 1-8-1, Shimo-Meguro, Meguro-ku, application by customer’s technical experts.
    [Show full text]
  • The Elinks Manual the Elinks Manual Table of Contents Preface
    The ELinks Manual The ELinks Manual Table of Contents Preface.......................................................................................................................................................ix 1. Getting ELinks up and running...........................................................................................................1 1.1. Building and Installing ELinks...................................................................................................1 1.2. Requirements..............................................................................................................................1 1.3. Recommended Libraries and Programs......................................................................................1 1.4. Further reading............................................................................................................................2 1.5. Tips to obtain a very small static elinks binary...........................................................................2 1.6. ECMAScript support?!...............................................................................................................4 1.6.1. Ok, so how to get the ECMAScript support working?...................................................4 1.6.2. The ECMAScript support is buggy! Shall I blame Mozilla people?..............................6 1.6.3. Now, I would still like NJS or a new JS engine from scratch. .....................................6 1.7. Feature configuration file (features.conf).............................................................................7
    [Show full text]
  • OSLC Architecture Management Specification 3.0 Project Specification Draft 01 17 September 2020
    Standards Track Work Product OSLC Architecture Management Specification 3.0 Project Specification Draft 01 17 September 2020 This stage: https://docs.oasis-open-projects.org/oslc-op/am/v3.0/psd01/architecture-management-spec.html (Authoritative) https://docs.oasis-open-projects.org/oslc-op/am/v3.0/psd01/architecture-management-spec.pdf Previous stage: N/A Latest stage: https://docs.oasis-open-projects.org/oslc-op/am/v3.0/architecture-management-spec.html (Authoritative) https://docs.oasis-open-projects.org/oslc-op/am/v3.0/architecture-management-spec.pdf Latest version: https://open-services.net/spec/am/latest Latest editor's draft: https://open-services.net/spec/am/latest-draft Open Project: OASIS Open Services for Lifecycle Collaboration (OSLC) OP Project Chairs: Jim Amsden ([email protected]), IBM Andrii Berezovskyi ([email protected]), KTH Editor: Jim Amsden ([email protected]), IBM Additional components: This specification is one component of a Work Product that also includes: OSLC Architecture Management Version 3.0. Part 1: Specification (this document). architecture-management- spec.html OSLC Architecture Management Version 3.0. Part 2: Vocabulary. architecture-management-vocab.html OSLC Architecture Management Version 3.0. Part 3: Constraints. architecture-management-shapes.html OSLC Architecture Management Version 3.0. Machine Readable Vocabulary Terms. architecture-management- vocab.ttl OSLC Architecture Management Version 3.0. Machine Readable Constraints. architecture-management-shapes.ttl architecture-management-spec Copyright © OASIS Open 2020. All Rights Reserved. 17 September 2020 - Page 1 of 19 Standards Track Work Product Related work: This specification is related to: OSLC Architecture Management Specification Version 2.0.
    [Show full text]
  • Introduction to Javascript
    Introduction to JavaScript Lecture 6 CGS 3066 Fall 2016 October 6, 2016 JavaScript I Dynamic programming language. Program the behavior of web pages. I Client-side scripts to interact with the user. I Communicates asynchronously and alters document content. I Used with Node.js in server side scripting, game development, mobile applications, etc. I Has thousands of libraries that can be used to carry out various tasks. JavaScript is NOT Java I Names can be deceiving. I Java is a full-fledged object-oriented programming language. I Java is popular for developing large-scale distributed enterprise applications and web applications. I JavaScript is a browser-based scripting language developed by Netscape and implemented in all major browsers. I JavaScript is executed by the browsers on the client side. JavaScript and other languages JavaScript borrows the elements from a variety of languages. I Object orientation from Java. I Syntax from C. I Semantics from Self and Scheme. Whats a script? I A program written for a special runtime environment. I Interpreted (as opposed to compiled). I Used to automate tasks. I Operates at very high levels of abstraction. Whats JavaScript? I Developed at Netscape to perform client side validation. I Adopted by Microsoft in IE 3.0 (1996). I Standardized in 1996. Current standard is ECMAScript 6 (2016). I Specifications for ECMAScript 2016 are out. I CommonJS used for development outside the browser. JavaScript uses I JavaScript has an insanely large API and library. I It is possible to do almost anything with JavaScript. I Write small scripts/apps for your webpage.
    [Show full text]
  • Towards the Second Edition of ISO 24707 Common Logic
    Towards the Second Edition of ISO 24707 Common Logic Michael Gr¨uninger(with Tara Athan and Fabian Neuhaus) Miniseries on Ontologies, Rules, and Logic Programming for Reasoning and Applications January 9, 2014 Gr¨uninger ( Ontolog Forum) Common Logic (ISO 24707) January 9, 2014 1 / 20 What Is Common Logic? Common Logic (published as \ISO/IEC 24707:2007 | Information technology Common Logic : a framework for a family of logic-based languages") is a language based on first-order logic, but extending it in several ways that ease the formulation of complex ontologies that are definable in first-order logic. Gr¨uninger ( Ontolog Forum) Common Logic (ISO 24707) January 9, 2014 2 / 20 Semantics An interpretation I consists of a set URI , the universe of reference a set UDI , the universe of discourse, such that I UDI 6= ;; I UDI ⊆ URI ; a mapping intI : V ! URI ; ∗ a mapping relI from URI to subsets of UDI . Gr¨uninger ( Ontolog Forum) Common Logic (ISO 24707) January 9, 2014 3 / 20 How Is Common Logic Being Used? Open Ontology Repositories COLORE (Common Logic Ontology Repository) colore.oor.net stl.mie.utoronto.ca/colore/ontologies.html OntoHub www.ontohub.org https://github.com/ontohub/ontohub Gr¨uninger ( Ontolog Forum) Common Logic (ISO 24707) January 9, 2014 4 / 20 How Is Common Logic Being Used? Ontology-based Standards Process Specification Language (ISO 18629) Date-Time Vocabulary (OMG) Foundational UML (OMG) Semantic Web Services Framework (W3C) OntoIOp (ISO WD 17347) Gr¨uninger ( Ontolog Forum) Common Logic (ISO 24707) January 9, 2014
    [Show full text]
  • APL Literature Review
    APL Literature Review Roy E. Lowrance February 22, 2009 Contents 1 Falkoff and Iverson-1968: APL1 3 2 IBM-1994: APL2 8 2.1 APL2 Highlights . 8 2.2 APL2 Primitive Functions . 12 2.3 APL2 Operators . 18 2.4 APL2 Concurrency Features . 19 3 Dyalog-2008: Dyalog APL 20 4 Iverson-1987: Iverson's Dictionary for APL 21 5 APL Implementations 21 5.1 Saal and Weiss-1975: Static Analysis of APL1 Programs . 21 5.2 Breed and Lathwell-1968: Implementation of the Original APLn360 25 5.3 Falkoff and Orth-1979: A BNF Grammar for APL1 . 26 5.4 Girardo and Rollin-1987: Parsing APL with Yacc . 27 5.5 Tavera and other-1987, 1998: IL . 27 5.6 Brown-1995: Rationale for APL2 Syntax . 29 5.7 Abrams-1970: An APL Machine . 30 5.8 Guibas and Wyatt-1978: Optimizing Interpretation . 31 5.9 Weiss and Saal-1981: APL Syntax Analysis . 32 5.10 Weigang-1985: STSC's APL Compiler . 33 5.11 Ching-1986: APL/370 Compiler . 33 5.12 Ching and other-1989: APL370 Prototype Compiler . 34 5.13 Driscoll and Orth-1986: Compile APL2 to FORTRAN . 35 5.14 Grelck-1999: Compile APL to Single Assignment C . 36 6 Imbed APL in Other Languages 36 6.1 Burchfield and Lipovaca-2002: APL Arrays in Java . 36 7 Extensions to APL 37 7.1 Brown and Others-2000: Object-Oriented APL . 37 1 8 APL on Parallel Computers 38 8.1 Willhoft-1991: Most APL2 Primitives Can Be Parallelized . 38 8.2 Bernecky-1993: APL Can Be Parallelized .
    [Show full text]
  • Technological Advancement in Object Oriented Programming Paradigm for Software Development
    International Journal of Applied Engineering Research ISSN 0973-4562 Volume 14, Number 8 (2019) pp. 1835-1841 © Research India Publications. http://www.ripublication.com Technological Advancement in Object Oriented Programming Paradigm for Software Development Achi Ifeanyi Isaiah1, Agwu Chukwuemeka Odi2, Alo Uzoma Rita3, Anikwe Chioma Verginia4, Okemiri Henry Anaya5 1Department of Maths/Comp Sci/Stats/Info., Faculty of science, Alex Ekwueme University, Ndufu-Alike 2Department of Computer Science, Ebonyi State University-Abakaliki. 3Alex Ekwueme University, Ndufu-Alike, 4Department of Maths/Comp Sci/Stats/Info., Faculty of science, Alex Ekwueme University, Ndufu-Alike 5Department of Maths/Comp Sci/Stats/Info., Faculty of science, Alex Ekwueme University, Ndufu-Alike Abstract and personalization problems. Take for instance, a lot of sophisticated apps are being produced and release in the Object oriented programming paradigm in software market today through the application of OOP. Almost desktop development is one of the most popular methods in the apps are being converted to mobile apps through Java, C++, information technology industry and academia as well as in PHP & MySQL, R, Python etc platform which form the many other forms of engineering design. Software testimony of OOP in the software industries. Software development is a field of engineering that came into existence developer has been revolving using procedural language for owing to the various problems that developers of software the past decade before the advent of OOP. The relationships faced while developing software projects. This paper analyzes between them is that procedural languages focus on the some of the most important technological innovations in algorithm but OOP focuses on the object model itself, object oriented software engineering in recent times.
    [Show full text]
  • NINETEENTH PLENARY MEETING of ISO/IEC JTC 1/SC 22 London, United Kingdom September 19-22, 2006 [20060918/22] Version 1, April 17, 2006 1
    NINETEENTH PLENARY MEETING OF ISO/IEC JTC 1/SC 22 London, United Kingdom September 19-22, 2006 [20060918/22] Version 1, April 17, 2006 1. OPENING OF PLENARY MEETING (9:00 hours, Tuesday, September 19) 2. CHAIRMAN'S REMARKS 3. ROLL CALL OF DELEGATES 4. APPOINTMENT OF DRAFTING COMMITTEE 5. ADOPTION OF THE AGENDA 6. REPORT OF THE SECRETARY 6.1 SC 22 Project Information 6.2 Proposals for New Work Items within SC 22 6.3 Outstanding Actions From the Eighteenth Plenary of SC 22 Page 1 of 7 JTC 1 SC 22, 2005 Version 1, April 14, 2006 6.4 Transition to ISO Livelink 6.4.1 SC 22 Transition 7. ACTIVITY REPORTS 7.1 National Body Reports 7.2 External Liaison Reports 7.2.1 ECMA International (Rex Jaeschke) 7.2.2 Free Standards Group (Nick Stoughton) 7.2.2 Austin Joint Working Group (Nick Stoughton) 7.3 Internal Liaison Reports 7.3.1 Liaison Officers from JTC 1/SC 2 (Mike Ksar) 7.3.2 Liaison Officer from JTC 1/SC 7 (J. Moore) Page 2 of 7 JTC 1 SC 22, 2005 Version 1, April 14, 2006 7.3.3 Liaison Officer from ISO/TC 37 (Keld Simonsen) 7.3.5 Liaison Officer from JTC 1 SC 32 (Frank Farance) 7.4 Reports from SC 22 Subgroups 7.4.1 Other Working Group Vulnerabilities (Jim Moore) 7.4.2 SC 22 Advisory Group for POSIX (Stephen Walli) 7.5 Reports from JTC 1 Subgroups 7.5.1 JTC 1 Vocabulary (John Hill) 7.5.2 JTC 1 Ad Hoc Directives (John Hill) 8.
    [Show full text]
  • Proposal to Refocus TC39-TG1 on the Maintenance of the Ecmascript, 3 Edition Specification
    Proposal to Refocus TC39-TG1 On the Maintenance of the ECMAScript, 3rd Edition Specification Submitted by: Yahoo! Inc. Microsoft Corporation Douglas Crockford Pratap Lakshman & Allen Wirfs-Brock Preface We believe that the specification currently under development by TC39-TG1 as ECMAScript 4 is such a radical departure from the current standard that it is essentially a new language. It is as different from ECMAScript 3rd Edition as C++ is from C. Such a drastic change is not appropriate for a revision of a widely used standardized language and cannot be justified in light of the current broad adoption of ECMAScript 3rd Edition for AJAX style web applications. We do not believe that consensus can be reach within TC39-TG1 based upon its current language design work. However, we do believe that an alternative way forward can be found and submit this proposal as a possible path to resolution. Proposal We propose that the work of TC39-TG1 be reconstituted as two (or possibly three) new TC39 work items as follows: Work item 1 – On going maintenance of ECMAScript, 3rd Edition. In light on the broad adoption of ECMAScript, 3rd Edition for web browser based applications it is clear that this language will remain an important part of the world-wide-web infrastructure for the foreseeable future. However, since the publication of the ECMAScript, 3rd Edition specification in 1999 there has been feature drift between implementations and cross-implementation compatibility issues arising from deficiencies and ambiguities in the specification. The purpose of this work item is to create a maintenance revision of the specification (a 4th Edition) that focuses on these goals: Improve implementation conformance by rewriting the specification to improve its rigor and clarity, and by correcting known points of ambiguity or under specification.
    [Show full text]
  • International Standard Iso/Iec 9075-2
    This is a previewINTERNATIONAL - click here to buy the full publication ISO/IEC STANDARD 9075-2 Fifth edition 2016-12-15 Information technology — Database languages — SQL — Part 2: Foundation (SQL/Foundation) Technologies de l’information — Langages de base de données — SQL — Partie 2: Fondations (SQL/Fondations) Reference number ISO/IEC 9075-2:2016(E) © ISO/IEC 2016 ISO/IEC 9075-2:2016(E) This is a preview - click here to buy the full publication COPYRIGHT PROTECTED DOCUMENT © ISO/IEC 2016, Published in Switzerland All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized otherwise in any form orthe by requester. any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address below or ISO’s member body in the country of Ch. de Blandonnet 8 • CP 401 ISOCH-1214 copyright Vernier, office Geneva, Switzerland Tel. +41 22 749 01 11 Fax +41 22 749 09 47 www.iso.org [email protected] ii © ISO/IEC 2016 – All rights reserved This is a preview - click here to buy the full publication ISO/IEC 9075-2:2016(E) Contents Page Foreword..................................................................................... xxi Introduction.................................................................................. xxii 1 Scope.................................................................................... 1 2 Normative references.....................................................................
    [Show full text]
  • Proof/Épreuve
    0- W e8 IE -2 V 07 E a3 ) 4 R i 68 P .a /5 -1 D h st 7 e si 75 R it s/ 1 A s. : d -2 rd r rf D rd a da p N a d n o- A d an ta is t /s c/ T n l s g 5 S ta l lo 8 s u a cc eh ( F at 0 /c fa iT ai c INTERNATIONAL . b0 eh a it - s. 43 STANDARD rd a9 a 1- nd f a 4b st // s: tp ht Document management for PDF — 21757-1 Part 1: Use of ISO 32000-2 (PDF 2.0) ISO First edition — ECMAScript PROOF/ÉPREUVE ISO 21757-1:2020(E)Reference number © ISO 2020 ISO 21757-1:2020(E) 0- W e8 IE -2 V 07 E a3 ) 4 R i 68 P .a /5 -1 D h st 7 e si 75 R it s/ 1 A s. : d -2 rd r rf D rd a da p N a d n o- A d an ta is t /s c/ T n l s g 5 S ta l lo 8 s u a cc eh ( F at 0 /c fa iT ai c . b0 eh a it - s. 43 rd a9 a 1- nd f a 4b st // s: tp ht © ISO 2020 All rights reserved. UnlessCOPYRIGHT otherwise specified, PROTECTED or required inDOCUMENT the context of its implementation, no part of this publication may be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission.
    [Show full text]