serialize Form

tipjs,object,es6

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

const serializeForm = form =>
  Array.from(new FormData(form), field => field.map(encodeURIComponent).join('=')).join('&');
// Sử dụng
serializeForm(document.querySelector('#form')); // email=test%40email.com&name=Test%20Name

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

Đếm số phần tử trong mảng JavaScript

Đếm số lần xuất hiện của các phần tử trong mảng JavaScript

Đếm có bao nhiêu items giống nhau trong một array

reduce javascript. Đếm có bao nhiêu items giống nhau trong một array

How to reverse an Array?

Reversing an array in JS is really simple with the standard array method. Like below

Lấy tháng hiện tại trong javascript

Lấy tháng hiện tại trong javascript

Merge Array

How to combine two sorted arrays into one? We can do this easily with the spread operator.