flatMap()

array,tipjs

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

[[2], [4], [6], [8]].flatMap(val => val/2) // [ 1, 2, 3, 4 ]

var new_array = arr.flatMap(function callback(currentValue[, index[, array]]) {
 // return element for new_array
}[, thisArg])

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

Filter Unique Values

Kiểu đối tượng Set đã được giới thiệu trong ES6 và cùng với ..., ‘spread’ operator, chúng ta có thể sử dụng nó để tạo một mảng mới chỉ với các giá trị duy nhất.

encode/decode base64 with JS

Encoding to base64 is done with the btoa command

Getting the last element of a split string array

Getting the last element of a split string array

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

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

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 .