随笔分类 -  ES6

摘要:We have new Arrayin Javascript const arr1 = new Array(3) // create an empty array with lengh 3 const arr2 = new Array(1,2,3) // create an array with v 阅读全文
posted @ 2025-06-02 14:06 Zhentiw 阅读(7) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-04-18 19:49 Zhentiw 阅读(152) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-26 16:08 Zhentiw 阅读(241) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-21 15:20 Zhentiw 阅读(210) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-17 14:38 Zhentiw 阅读(206) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-11 03:38 Zhentiw 阅读(247) 评论(0) 推荐(0)
摘要: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 ( 阅读全文
posted @ 2017-09-14 01:05 Zhentiw 阅读(218) 评论(0) 推荐(0)
摘要:A JavaScript Proxy allows you to intercept operations performed on objects, arrays, or functions like property lookup, assignment, invocation, propert 阅读全文
posted @ 2017-01-11 21:48 Zhentiw 阅读(199) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-02-17 02:22 Zhentiw
摘要:Example 1:function *topicList(){ yield "ES2015"; yield "Semi-colons: good or bad?"; yield "TypeScript";}for( let topic of topicList() ){ console.l... 阅读全文
posted @ 2016-01-14 21:16 Zhentiw
摘要: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 ... 阅读全文
posted @ 2016-01-14 21:07 Zhentiw
摘要:How to use:export default function getReplies(topicId){ return new Promise(function( resolve, reject ){ _getRepliesForTopic(topicId, function(data... 阅读全文
posted @ 2016-01-14 20:54 Zhentiw
摘要:Export variable:export const MAX_USERS = 3;export const MAX_REPLIES = 3;Export default class:export default class FlashMessage { constructor(message)... 阅读全文
posted @ 2016-01-14 20:34 Zhentiw
摘要:Default export:Default export is easy way to export a function to outside module.//flash-message.jsexport default function(message){ alert(message);... 阅读全文
posted @ 2016-01-14 20:17 Zhentiw
摘要:In constructor, you can call parent's constuctor() method by supert();class ShoppingCart { constructor(userId){ this.userId = userId; this.prod... 阅读全文
posted @ 2016-01-14 20:02 Zhentiw
摘要:Limitations With ArrayArrays don't enforce uniqueness of items. Diplicate entries are allowed.Using Setslet tags = new Set() ;tags.add('Javascript');t... 阅读全文
posted @ 2016-01-14 04:11 Zhentiw
摘要: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... 阅读全文
posted @ 2016-01-14 04:07 Zhentiw
摘要:Use Maps when keys are unknown until runtime:Map:let recentPosts = new Map();createPost( newPost, (data)=>{ // Key unknown until runtime, so use Ma... 阅读全文
posted @ 2016-01-14 03:35 Zhentiw
摘要: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... 阅读全文
posted @ 2016-01-13 02:42 Zhentiw
摘要:We can use the destructing and rest parameters at the same time when dealing with Array opration.Example 1:let [first, ...remainingUsers] = ["Sam", "T... 阅读全文
posted @ 2016-01-04 03:21 Zhentiw