随笔分类 - Javascript
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static concnat(..
阅读全文
摘要:function Observable(forEach) { this._forEach = forEach; } Observable.prototype = { forEach: function (onNext, onError, onCompleted) { if (typeof onNex
阅读全文
摘要:<Parent> <child> <button /> </child> </Parent> function onClick(event) { console.log('target: ', event.target) // button console.log('currentTarget',
阅读全文
摘要:Mistake 1: Not using the same function reference // Wrong button.addEventListener('click', () => {console.log('click')}) button.removeEventListener('c
阅读全文
摘要:When Virtual keyboard popup, we can relayout the UI element accordingly: navigator.virtualKeyboard.overlaysContent = true; navigator.virtualKeyboard.s
阅读全文
摘要:Run the following code, found that for get & push & pop, it is O(1) time; But for shift/unshfit, it is O(n) time. In this cases, Javascript's [], is a
阅读全文
摘要:const $ = () => document.querySelector.call(this, arguments); const $$ = () => document.querySelectorAll.call(this, arguments); HTMLElement.prototype.
阅读全文
摘要:Solution 1: consider change font-size to 16px or above Soution 2: using javascript if(navigator.userAgent.indexOf('iPhone') > -1 ) { document .querySe
阅读全文
摘要:What this refer to? function regularFunction() { this // Global scope } const obj = { regularFunction() { this // The object on which the method is ca
阅读全文
摘要:Once run in async await, the rest of the function body will be push to Microtask Queue console.log(3) Order: 2 3 4 1
阅读全文
摘要:What gets logged when clicking button? <div id="outer"> <div id="inner"> <button id="btn">Click me!</button> </div> </div> const outer = document.getE
阅读全文
摘要:Layout: This step invovles determining the geometry of the page. The browser calculates where each element will be on the screen, considering factors
阅读全文
摘要:JavaScript, the programming language of the web, is often praised for its ability to handle memory management automatically. The JavaScript engine's g
阅读全文
摘要:DOM (Documnet Object Model) Tree: When a web page is loaded, the browser reads the HTML and builds the DOM tree. The DOM is a tree-like structure that
阅读全文
摘要:normal script, without async defer: Script fetched and executed immediately, before browser continues parsing the page (It stops HTML parsing). If the
阅读全文
摘要:button.addEventListener( 'click', (event) => { console.log('listener 1') queueMicrotask(() => { console.log('microtask') }) } ) button.addEventListene
阅读全文
摘要:You can use getEventListeners(button)directly inside chrome devtool, but not inside application code. You can use monitorEvents(button, 'keydown'), no
阅读全文
摘要:Difference between yieldand return returnset doneto true /** * Example 1 */ function* loggerator() { console.log("running"); yield "paused"; console.l
阅读全文
摘要:Blog: https://dev.to/marclipovsky/discovering-the-power-of-javascript-proxy-after-all-this-time-4627 Lazy loading: const lazyLoadHandler = { get: func
阅读全文
摘要:reverse()mutates the original array, return the reference point to the original array. The toReversed() method of Array instances is the copying count
阅读全文