Lấy tháng hiện tại trong javascript

date,tipjs,function

Lấy tháng hiện tại trong javascript

const getMonth = (fillFlag=true) => {
  const mon = new Date().getMonth() + 1
  const monRe = mon
  if (fillFlag) mon < 10 ? `0${mon}` : mon
  return monRe
}
console.log(getMonth());//5

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

flatMap()

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

formatdate js

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

Làm phẳng mảng dùng phương pháp đệ quy

Làm phẳng mảng dùng phương pháp đệ quy

try/catch es10

An update for developer convience allows the use of try/catch without an explicit e Error reference in the catch call.

JavaScript: async/await with forEach

JavaScript: async/await with forEach()