随笔分类 - Javascript
只有注册用户登录后才能阅读该文。
摘要:When the ES6 class shipped back in 2015, a number of additional keywords came with it. Two of these are constructor and super. Both of these are speci
阅读全文
摘要:Classes are syntactic sugar over functions and functions are also referred to as "callable" objects. So it is possible to treat a function like an obj
阅读全文
摘要:An IIFE (immediately invoked function expression) is when a function is called immediately after it is defined. These functions are defined and called
阅读全文
摘要:For example, we have a 2D arrays; We want to sort by the number first, if the number are the same, then we want to sort by name DESC: So the result sh
阅读全文
摘要:function addTo80(n ) { return 80 + n; } function memoizedAddTo80 (fn) { let cache = {}; return (n) => { /*keyword 'in' to check prop exists*/ if (n in cache) { console.log('from cache') return cache[n
阅读全文
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
摘要:const isPromise = obj => Boolean(obj) && typeof obj.then 'function'; This can be a tool save into your toolbox.
阅读全文
摘要:JavaScript is single-threaded, which can present some problems when creating an interactive user experience. If JavaScript runs too long while a user
阅读全文
只有注册用户登录后才能阅读该文。
摘要:window.matchMedia() allow to listen to browser window size changes and trigger the callback for different media query size. you can attach a listener
阅读全文
摘要:For example we have a 'useState' function, which takes a state and a function to update the state: const useState = (state, setState) => { const newSt
阅读全文
摘要:regexr is a powerful tool for debugging existing regexes and creating new ones. In this lesson, we'll use the app to create a regex that matches Twitt
阅读全文
摘要:This can be handy if you have a rate limit on API requests or if you need to pass the result of each promise to the next one. function fetchMessages(u
阅读全文
摘要:Most developers are familiar with using img tags and assigning the src inside of HTML. It is also possible to only use JavaScript to fetch the image f
阅读全文
摘要:For example we have a 'forEach' method which can loop though a linked list: Test: What if we want to use for...of loop? Then we need to convert Linked
阅读全文
摘要:ES2019 introduces the Symbol.prototype.description property. In this lesson, we'll learn why this property is useful and unlocks Symbols as appropriat
阅读全文
摘要:ES2019 introduces the Array.prototype.flatMap method. In this lesson, we'll investigate a common use case for mapping and filtering an array in a sing
阅读全文