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

date,tipjs,function

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

const getDay = (fillFlag=true) => {
  const day = new Date().getDate()
  const dayRe = day
  if (fillFlag) day < 10 ? `0${day}` : day
  return dayRe
}

//Ouput:
console.log(getDay());//27

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

Async await in javascript

Async await in javascript

Spread Operator for Objects

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

Getting the last element of a split string array

Getting the last element of a split string array

Callback in javascript

Callback in javascript

JavaScript: async/await with forEach

JavaScript: async/await with forEach()