随笔分类 -  Javascript

上一页 1 2 3 4 5 6 7 8 9 10 ··· 30 下一页
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static concnat(.. 阅读全文
posted @ 2023-09-12 15:44 Zhentiw 阅读(10) 评论(0) 推荐(0)
摘要:function Observable(forEach) { this._forEach = forEach; } Observable.prototype = { forEach: function (onNext, onError, onCompleted) { if (typeof onNex 阅读全文
posted @ 2023-09-05 20:57 Zhentiw 阅读(14) 评论(0) 推荐(0)
摘要:<Parent> <child> <button /> </child> </Parent> function onClick(event) { console.log('target: ', event.target) // button console.log('currentTarget', 阅读全文
posted @ 2023-08-04 16:11 Zhentiw 阅读(25) 评论(0) 推荐(0)
摘要:Mistake 1: Not using the same function reference // Wrong button.addEventListener('click', () => {console.log('click')}) button.removeEventListener('c 阅读全文
posted @ 2023-07-27 15:13 Zhentiw 阅读(92) 评论(0) 推荐(0)
摘要:When Virtual keyboard popup, we can relayout the UI element accordingly: navigator.virtualKeyboard.overlaysContent = true; navigator.virtualKeyboard.s 阅读全文
posted @ 2023-07-24 15:35 Zhentiw 阅读(51) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2023-07-20 14:34 Zhentiw 阅读(7) 评论(0) 推荐(0)
摘要:const $ = () => document.querySelector.call(this, arguments); const $$ = () => document.querySelectorAll.call(this, arguments); HTMLElement.prototype. 阅读全文
posted @ 2023-07-18 20:41 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要:Solution 1: consider change font-size to 16px or above Soution 2: using javascript if(navigator.userAgent.indexOf('iPhone') > -1 ) { document .querySe 阅读全文
posted @ 2023-07-17 17:16 Zhentiw 阅读(13) 评论(0) 推荐(0)
摘要:What this refer to? function regularFunction() { this // Global scope } const obj = { regularFunction() { this // The object on which the method is ca 阅读全文
posted @ 2023-06-26 02:05 Zhentiw 阅读(23) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2023-06-26 01:46 Zhentiw 阅读(26) 评论(0) 推荐(0)
摘要:What gets logged when clicking button? <div id="outer"> <div id="inner"> <button id="btn">Click me!</button> </div> </div> const outer = document.getE 阅读全文
posted @ 2023-06-20 14:10 Zhentiw 阅读(12) 评论(0) 推荐(0)
摘要:Layout: This step invovles determining the geometry of the page. The browser calculates where each element will be on the screen, considering factors 阅读全文
posted @ 2023-06-19 15:12 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:JavaScript, the programming language of the web, is often praised for its ability to handle memory management automatically. The JavaScript engine's g 阅读全文
posted @ 2023-06-19 14:12 Zhentiw 阅读(31) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2023-06-11 17:50 Zhentiw 阅读(24) 评论(0) 推荐(0)
摘要:normal script, without async defer: Script fetched and executed immediately, before browser continues parsing the page (It stops HTML parsing). If the 阅读全文
posted @ 2023-06-11 17:19 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要:button.addEventListener( 'click', (event) => { console.log('listener 1') queueMicrotask(() => { console.log('microtask') }) } ) button.addEventListene 阅读全文
posted @ 2023-06-02 20:59 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要:You can use getEventListeners(button)directly inside chrome devtool, but not inside application code. You can use monitorEvents(button, 'keydown'), no 阅读全文
posted @ 2023-06-02 20:51 Zhentiw 阅读(19) 评论(0) 推荐(0)
摘要:Difference between yieldand return returnset doneto true /** * Example 1 */ function* loggerator() { console.log("running"); yield "paused"; console.l 阅读全文
posted @ 2023-05-25 17:39 Zhentiw 阅读(9) 评论(0) 推荐(0)
摘要:Blog: https://dev.to/marclipovsky/discovering-the-power-of-javascript-proxy-after-all-this-time-4627 Lazy loading: const lazyLoadHandler = { get: func 阅读全文
posted @ 2023-05-04 13:45 Zhentiw 阅读(22) 评论(0) 推荐(0)
摘要:reverse()mutates the original array, return the reference point to the original array. The toReversed() method of Array instances is the copying count 阅读全文
posted @ 2023-05-02 14:06 Zhentiw 阅读(26) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 10 ··· 30 下一页