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

kiểm tra email trong javascript

kiểm tra email trong javascript

Merge Array

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

How to reverse an Array?

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

10 mẹo sử dụng array và object trong javascript

10 mẹo sử dụng array và object trong javascript

Chuyển đổi thời gian trong javascript

Sử dụng Object.entries(), Array.prototype.filter() và Array.prototype.map(). Trả về định dạng ngày, giờ, phút với một miliseconds đã cho.