How to reverse an Array?

array,tipjs

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

const str = ['a', 'b', 'c', 'd', 'e'];
console.log(str.reverse());
// Output: > Array ["e", "d", "c", "b", "a"]

Without using reverse() method:

const str = ['a', 'b', 'c', 'd', 'e'];
const str1 = [];
  for (let i = str.length - 1; i >= 0; i--) {
str1.push(str[i]);
  }
console.log(str1);
// Output: > Array ["e", "d", "c", "b", "a"]

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

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

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

Converting Object to an Array

Converting Object to an Array

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.

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

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