Rolling loading

tipjs,object,es6

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 , scrollTopscrollHeight .

window.addEventListener('scroll', function() {
  const clientHeight = document.documentElement.clientHeight;
  const scrollTop = document.documentElement.scrollTop;
  const scrollHeight = document.documentElement.scrollHeight;
  if (clientHeight + scrollTop >= scrollHeight) {
    // Xử lý ở đây
    // ...
  }
}, false);

Có thể bạn đã miss một số snippets code

flatMap()

Use flatMap() creates a new array with sub-array elements flattened by specified depth.

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.

promise in javascript

promise in javascript

encode/decode base64 with JS

Encoding to base64 is done with the btoa command

serialize Form

Sử dụng formdata constructor để convert form, FormData, array.from(). Kết hợp window.encodeURIComponent() để encode từng value trong form.