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

Random String

Random String với độ dài tuỳ chọn

Random Number javascript

Random Number javascript

Object.keys và Object.getOwnPropertyNames

Object.keys và Object.getOwnPropertyNames

Getting the last element of a split string array

Getting the last element of a split string array

encode/decode base64 with JS

Encoding to base64 is done with the btoa command