I was working with dates and such:
window.onload = () => {
setInterval(
() => {
let currentTimeObj = new Date()
let {currentSeconds: getSeconds()} = currentTimeObj ;
currentTime.innerHTML = `${currentSeconds} `;
}
, 1000);
};
Problem is I want to assign the method from the date object called, getSeconds()
to a variable and use it as a template literal. I'm trying to destructure getDay()
, getHours()
, etc. 'cause I want to do it on one line. If that isn't possible, or isn't reccomended, please tell me.
It outputs, Invalid destructuring assignment target
, I've looked that up on google, I didn't get any clue what to do.
Got any tips? If not all I can think of doing is using the ol' fashioned
"..." + variable + "..."
.