Es6 map and set objects! ! !

ES6 Map Map object Map objects hold key-value pairs. Any value (object or primitive) can be used as a key or a value. let mapObj = new Map(); Map features Map objects hold key-value pairs. Any value (object or primitive) can be used as a key or a value. Map objects remember the original insertion […]

ES6 Iterator and for…of loops

1.iterator concept ES6 added Map and Set. So there are four data collections, and a unified interface mechanism is needed to handle all different data structures. Iterator is such a mechanism. It is an interface that provides a unified access mechanism for various different data structures. As long as any data structure deploys the Iterator […]

ES6 — Modularity (CommonJS, AMD, ES Module)

Module mode Splitting the code into independent chunks and then connecting these chunks together can be achieved through the module pattern. The idea behind this model is simple: divide the logic into blocks, encapsulate each one, and make it independent of each other. Each block decides on its own what to expose to the outside […]

A thorough understanding of front-end ES6 modularity in one article

This article thoroughly understands the front-end ES6 modularity 1 Introduction 2. Front-end modular specification 3. What is the ES6 modular specification? 4. Experience ES6 modularity in node.js 5. Basic syntax of ES6 modularization 5.1 Default export and default import 5.2 On-demand export and on-demand import 5.3 Directly import and execute the code in the module […]

ES6 adds new promise object

Reason for writing There are two traditional solutions to asynchronous problems: With callback function Depends on events => Custom events => Dispatched when the request is successful (data is stored in the event object) Traditional solution code implementation Solving asynchronous problems with callback functions var xhr = new XMLHttpRequest(); xhr.open(“get”, “../data/goods.json”, true); xhr.send(); // Bind […]

JavaScript ES6 syntax

JavaScript ES6 syntax Code download ES6 related concepts The full name of ES is ECMAScript, which is a standardized specification for scripting languages formulated by the ECMA International Standards Organization. ES6 is actually a general term that refers to ES2015 and subsequent versions. Year Version 2015768 ES2015 2016768 ES2016 2017468 ES2017 201868 ES2018 The birth […]

WeakMap and WeakSet in ES6: Features and Purpose

Jiangcheng Cheerful Pea: Personal homepage Personal column :《VUE》《javaScript》 The ideal of life is for an ideal life! Table of Contents 1. Overview of WeakMap and WeakSet 1.1 WeakMap 1.2 WeakSet 2. In-depth analysis of WeakMap 2.1 Creation and use of WeakMap 2.2 WeakMap and memory management 2.3 WeakMap and object private data 3. In-depth analysis […]

Extensions to arrays in ES6

1. Extension operator Represented by three dots (…), it is like the inverse operation of the rest parameter, converting the array into a comma-separated parameter sequence. Extension is to divide a collection into individual ones. console.log(…[1, 2, 3]); // 1, 2, 3 Can be used for function calls Expressions can also be placed after the […]

Variable destructuring and assignment in ES6

Destructuring assignment of array ES6 stipulates that extracting values from arrays and objects in a certain pattern, and then assigning values to variables is called destructuring. It is essentially a matching pattern. If the pattern on both sides of the equal sign is the same, the variable on the left can correspond to the value. […]

Extensions to objects in ES6

1. Concise representation of attributes Variables and functions can be written directly as properties and methods of objects. Writing only the attribute name and not the attribute value in the object means that the attribute value is equal to the value of the variable with the same attribute name. Abbreviation for attribute let foo = […]