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());//27Có thể bạn đã miss một số snippets code
Tránh viết biến có phạm vi global
Đôi khi bạn cần phải viết một tập lệnh trực tiếp trên trang. Cần lưu ý rằng trong code của bạn vô tình khai báo một biến toàn cầu. Vì phạm vi toàn cầu phức tạp hơn nên việc tìm kiếm chậm hơn rất nhiều
try/catch es10
An update for developer convience allows the use of try/catch without an explicit e Error reference in the catch call.
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
Đếm có bao nhiêu items giống nhau trong một array
reduce javascript. Đếm có bao nhiêu items giống nhau trong một array