As the title says I want to dynamically assign today's date as string in "DD/MM/YYYY" format to the property. It has to be dynamically calculated and assigned right next to the objects property declaration.
I figured something like this:
var obj = {
today: `${(new Date).getDate()}/${(new Date).getMonth()}/${(new Date).getFullYear()}`
};
Which works perfect BUT it's obviously not efficient as it creates three new Date instances. I would like to do it something like this:
var obj = {
today: (
const today = new Date;
return `${today.getDate()}/${today.getMonth()}/${today.getFullYear()}`
)
};
Thanks!