随笔分类 - Javascript
摘要:Learn how to use custom events to expose internal events from withing a web component. class MyWelcome extends HTMLElement { constructor() { super();
阅读全文
摘要:What makes objects different is that we can create more of them. Every time we use the {} object literal, we create a brand new object value: let shre
阅读全文
摘要:Let's see a simple code example: let pet = "dog" console.log(pet) We have console.log(pet) inside the code, when you read it, you might say: Pass ´pet
阅读全文
摘要:It can be confusing to understand when and how the .prototype and .proto properties are created and used. They both seem to imply having something to
阅读全文
摘要:"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
阅读全文

浙公网安备 33010602011771号