Web API
The Dangers of Stopping Event Propagation
https://css-tricks.com/dangers-stopping-event-propagation/
TextEncoder
https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
- String length in bytes in JavaScript
https://stackoverflow.com/questions/5515869/string-length-in-bytes-in-javascript
(new TextEncoder().encode('foo')).length
Optional Chaining ?.
https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Operators/Optional_chaining
筆記
-
如果一個 div 擋在 link 前面,即便 div 是透明的,還是按不到那個 link
-
用 JavaScript 得到 URL 的 Query String (location.search)
// 假設 "?q=1234"
let urlParams = new URLSearchParams(window.location.search);
console.log(urlParams.get('q')); // "1234"
Used 使用過
- Element.getBoundingClientRect()
https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
(Learned by hotfix - Blog index category) - matchMedia
https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia array.some
vsarray.forEach
:some
做到第一個 true 就結束了,forEach
會做完所有 array
To Learn
- intersection observer API
- session storage
在頁面關掉後, session storage 內容也隨之清除