Clone Objects in JavaScript
object,tipjs
Clone Objects in JavaScript
const food = { beef: '🥩', bacon: '🥓' }
// "Spread"
{ ...food }
// "Object.assign"
Object.assign({}, food)
// "JSON"
JSON.parse(JSON.stringify(food))
// RESULT:
// { beef: '🥩', bacon: '🥓' }Có thể bạn đã miss một số snippets code
Convert Array-like to True Array
Convert Array-like to True Array
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 .
serialize Form
Sử dụng formdata constructor để convert form, FormData, array.from(). Kết hợp window.encodeURIComponent() để encode từng value trong form.
Using promises to catch errors
Ajax, call jQuery POST to node.js expressjs
Ajax, call jQuery POST to node.js expressjs