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

Sự khác biệt giữa substr và substring

Sự khác biệt giữa substr() và substring() chức năng trong JS là gì?

using javascript callback style error handling

lỗi access-control-allow-origin và cách khắc phục

lỗi access-control-allow-origin và cách khắc phục trong express, nodejs

encode/decode base64 with JS

Encoding to base64 is done with the btoa command

Remove item in array javascript es6

Những bạn nào mà đã sử dụng ES6 một thời gian rồi thì có thể sử dụng method array.filter()