Convert Array-like to True Array
object,array,tipjs
This is cool! Learning something new @wesbos ES6 course 🔥
const nodeList = document.querySelectorAll('ul li');
// Method 1: Convert to true Array
Array.from(nodeList);
// Method 2: Convert to true Array
[...nodeList];
// Now you can use map and other methods to loopCó thể bạn đã miss một số snippets code
Tránh viết biến có phạm vi global
Đôi khi bạn cần phải viết một tập lệnh trực tiếp trên trang. Cần lưu ý rằng trong code của bạn vô tình khai báo một biến toàn cầu. Vì phạm vi toàn cầu phức tạp hơn nên việc tìm kiếm chậm hơn rất nhiều
Làm phẳng mảng dùng phương pháp đệ quy
Làm phẳng mảng dùng phương pháp đệ quy
serialize Form
Sử dụng formdata constructor để convert form, FormData, array.from(). Kết hợp window.encodeURIComponent() để encode từng value trong form.
Clone Objects in JavaScript
3 Ways to Clone Objects in JavaScript
Convert Array-like to True Array
Convert Array-like to True Array