随笔分类 -  Javascript

上一页 1 2 3 4 5 6 7 8 9 ··· 30 下一页
摘要:function logThis() { console.log(this) } const obj = { logThis, logThis2() { logThis() }, logThis3() { obj.logThis() } } obj.logThis(); obj.logThis2() 阅读全文
posted @ 2024-02-29 22:11 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:Web API, such as setTimeout setInterval which goes into Macrotask Queue; Microtask such as, code after await, Promise, all go to Microtask Queue direc 阅读全文
posted @ 2024-02-26 16:03 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:Refer to post: http://shebang.mintern.net/foolproof-html-escaping-in-javascript/ Code: var ESC_MAP = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '& 阅读全文
posted @ 2023-11-23 15:41 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要:const generateTimeMs = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min /** * A generator which can generate numbers based on settings 阅读全文
posted @ 2023-11-18 17:25 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static of(value) 阅读全文
posted @ 2023-09-12 16:04 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:class Observable { constructor(subscribe) { this._subscribe = subscribe; } subscribe(observer) { return this._subscribe(observer); } static concnat(.. 阅读全文
posted @ 2023-09-12 15:44 Zhentiw 阅读(3) 评论(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 阅读(3) 评论(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 阅读(9) 评论(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 阅读(78) 评论(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 阅读(37) 评论(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 阅读(3) 评论(0) 推荐(0) 编辑
摘要:const $ = () => document.querySelector.call(this, arguments); const $$ = () => document.querySelectorAll.call(this, arguments); HTMLElement.prototype. 阅读全文
posted @ 2023-07-18 20:41 Zhentiw 阅读(22) 评论(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 阅读(8) 评论(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 阅读(16) 评论(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 阅读(17) 评论(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 阅读(4) 评论(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 阅读(10) 评论(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 阅读(16) 评论(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 阅读(13) 评论(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 阅读(16) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 30 下一页
点击右上角即可分享
微信分享提示