随笔分类 - Javascript
摘要:"let" keyword, the same as "const" does hoist the variable. But different from 'var', it does both hoist and assign value as "undefined". "let" in oth
阅读全文
摘要:The Promise.any() method accepts an array (or any other iterable) of promises as a parameter. It returns a Promise object that is fulfilled with the v
阅读全文
摘要:The Promise.allSettled() method accepts an array (or any other iterable) of promises as a parameter. It returns a Promise object that is fulfilled wit
阅读全文
摘要:In Javascript, there are two types of event loops for async tasks. First one, is well known one, for example, setTimeout, http request, click event wi
阅读全文
摘要:Primitive Values Undefined (undefined), used for unintentionally missing values. Null (null), used for intentionally missing values. Booleans (true an
阅读全文
摘要:Sometimes we need to prevent some properties on a JavaScript object from being iterated over and accessed in "for ... in" loops. In this lesson, we wi
阅读全文
摘要:function looksLike(a, b) { return ( a && b && Object.keys(b).every(bKey => { const bVal = b[bKey] const aVal = a[bKey] if (typeof bVal 'function') { r
阅读全文
摘要:There are several fundamental problems with trying to manage the state of a function through the use of booleans. The first is often referred to as "b
阅读全文
摘要:Generators offer flexible alternatives to working with arrays and how you want to iterate through the data. While most scenarios are covered by the me
阅读全文
摘要:Generator functions are great at generating data. You can create all types of functions that take params to define what sort of data to generate. The
阅读全文
摘要:Since generators can take initial values and expose a next method which can run updates on the initial value, it becomes trivial to make a state machi
阅读全文
摘要:Generators emulate the behavior of a closure where they wrap an initial value then can take subsequent values through next to yield something based on
阅读全文
摘要:Generators allow you to hook together multiple generators with the yield* syntax. This allows you to branch off into many different types of iteration
阅读全文
摘要:Generators allow you to use the yield * syntax to yield each iteration of nested iterable as part of the main iterations. This enables you to combine
阅读全文
摘要:Using Symbol.iterator, you can create custom iterators that can be used inside of for loops and Array spreads. This lesson walks you through creating
阅读全文
摘要:Iterators are the foundation of generators. Much of the misunderstanding around generators comes from the lack of understanding iterators. An iterator
阅读全文
摘要:Every Array has a function which you can use to create an iterator. This function can only be accessed by using the Symbol.iterator as a key on the Ar
阅读全文
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。