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

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.

Hàm lày ngày trong tuần javascript

Hàm lày ngày trong tuần javascript

flatMap()

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

Merge Array

How to combine two sorted arrays into one? We can do this easily with the spread operator.

Convert Array-like to True Array

Convert Array-like to True Array