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

Rolling loading

Nguyên tắc là theo dõi các sự kiện cuộn trang và phân tích mối quan hệ thuộc tính giữa clientHeight , scrollTop và scrollHeight .

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.

flatMap()

Use flatMap() creates a new array with sub-array elements flattened by specified depth.

Spread Operator for Objects

Using the spread operator during an Object declaration will assign the properties of the referenced Object to the new Object.

closure javascript

closure javascript