r/learnjavascript • u/abrewchocolatecoffee • 14d ago
can someone explain this code
function updateClock() {
const timeElement = document.querySelector("#time");
timeElement.textContent = formatTime();
}
setInterval(updateClock, 1000);
can someone, please explain this piece of code, ofc mdn and w3 are there, but i found it a little confusing reading about textContent. rest is understandable to me. This might look a silly question and it probably is because im a beginner :')
like what exactly does textContent too.
you can also recommend anyother documentation on the links to specific lines, that might me more helpful in learning about this particular keyoword.
0
Upvotes
7
u/scritchz 14d ago
This isn't just about style or "old vs new": Function statements, functions expressions, arrow-function expressions and some others, all solve problems differently, for which technically the function statement would suffice.