随笔分类 - ES6
摘要:Proxy and Reflect API works nicely together. About how to use Proxy, check this post. Let's see about Reflect API: For proxy and Reflect, their API is
阅读全文
摘要:What a Proxy does is handle communication for an Object. To create a proxy object, we use the Proxy constructor - new Proxy();. The proxy constructor
阅读全文
摘要:The iterator protocol is used to define a standard way that an object produces a sequence of values. What that really means is you now have a process
阅读全文
摘要:A symbol is a unique and immutable data type that is often used to identify object properties. To create a symbol, you write Symbol() with an optional
阅读全文
摘要:ES6 class with extends and super: How this is written in ES5: We use 'Tree.call(this)' to pass context, 'this' is refer to Maple because of Clourse. T
阅读全文
摘要:In this lesson we will understand the For Of loop in Javascript which was introduced in ES6. The for-of loop lets you iterate of an itterable object (
阅读全文
摘要:A JavaScript Proxy allows you to intercept operations performed on objects, arrays, or functions like property lookup, assignment, invocation, propert
阅读全文
摘要:ES6: If you know about the Javascirpt's event loop. You know that any asyns opreations will be throwed to the end to loop, such as 'setTimeout, http c
阅读全文
摘要:Example 1:function *topicList(){ yield "ES2015"; yield "Semi-colons: good or bad?"; yield "TypeScript";}for( let topic of topicList() ){ console.l...
阅读全文
摘要:Iterables return an iterator object. This object knows how to access items from a collection 1 at a time, while keeping track of its current position ...
阅读全文
摘要:How to use:export default function getReplies(topicId){ return new Promise(function( resolve, reject ){ _getRepliesForTopic(topicId, function(data...
阅读全文
摘要:Export variable:export const MAX_USERS = 3;export const MAX_REPLIES = 3;Export default class:export default class FlashMessage { constructor(message)...
阅读全文
摘要:Default export:Default export is easy way to export a function to outside module.//flash-message.jsexport default function(message){ alert(message);...
阅读全文
摘要:In constructor, you can call parent's constuctor() method by supert();class ShoppingCart { constructor(userId){ this.userId = userId; this.prod...
阅读全文
摘要:Limitations With ArrayArrays don't enforce uniqueness of items. Diplicate entries are allowed.Using Setslet tags = new Set() ;tags.add('Javascript');t...
阅读全文
摘要:WeakMap: is a type of Map where only objects can be passed as keys. Primitive data type -- such are string, numbers, booleans, etc --- are not allowed...
阅读全文
摘要:Use Maps when keys are unknown until runtime:Map:let recentPosts = new Map();createPost( newPost, (data)=>{ // Key unknown until runtime, so use Ma...
阅读全文
摘要:Map is really useful when you want to use object as a key to set vaule, in ES5, you cannot really use object as a key:var user1 = { name: "Wan", age...
阅读全文
摘要:We can use the destructing and rest parameters at the same time when dealing with Array opration.Example 1:let [first, ...remainingUsers] = ["Sam", "T...
阅读全文
摘要:function spinner(target, options = {}){ let defaults = { message: "Please wait", spinningSpeed: 5, cssClass: ".is-spinning" }; let setting...
阅读全文