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

try/catch es10

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

String.prototype.trimEnd

trimEnd() Phương thức xóa khoảng trắng từ đầu chuỗi và trả về một chuỗi mới. Có nghĩa là trimEnd() xoá những ký tự space bên phải mà không làm thay đổi chuỗi gốc.

Copy a string to the clipboard

Copy a string to the clipboard. Only works as a result of user action (i.e. inside a click event listener).

using javascript callback style error handling

Sử dụng reduce và concat làm phẳng một array

Array.reduce() và Array.concat() có thể giúp chúng ta làm phẳng một Array như: