Calculate the number of difference days between two dates

es6,date

Calculate the number of difference days between two dates

const diffDays = (date, otherDate) => Math.ceil(Math.abs(date - otherDate) / (1000 * 60 * 60 * 24));

// diffDays(new Date('2014-12-19'), new Date('2020-01-01')) === 1839

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

formatdate js

JavaScript’s Date() function object contains a long list of methods that can be used to manipulate the date outcome

Await in a for loop

How to Await in a for loop

Spread Operator for Objects

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

Using promises to catch errors

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