Tránh viết biến có phạm vi global
tipjs,scope,global
Không nên
var map = document.querySelector("#my-map");
map.style.height = "600px";
Nên
!function(){
var map = document.querySelector("#my-map");
map.style.height = "600px";
}()Có thể bạn đã miss một số snippets code
Merge Array
How to combine two sorted arrays into one? We can do this easily with the spread operator.
Convert Array-like to True Array
Convert Array-like to True Array
Callback in javascript
Callback in javascript
Copy a string to the clipboard
Copy a string to the clipboard. Only works as a result of user action (i.e. inside a click event listener).
Rolling loading
Nguyên tắc là theo dõi các sự kiện cuộn trang và phân tích mối quan hệ thuộc tính giữa clientHeight , scrollTop và scrollHeight .