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

Callback in javascript

Callback in javascript

Đế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

Copy a string to the clipboard

Copy a string to the clipboard. Only works as a result of user action (i.e. inside a click event listener).

Random Number javascript

Random Number javascript

Hàm lày ngày trong tuần javascript

Hàm lày ngày trong tuần javascript