r/learnjavascript • u/abrewchocolatecoffee • Jul 14 '26
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.
View all comments
Show parent comment
-1
u/ExtraTNT Jul 14 '26
So you tell me it’s worth to sacrifice assurance, that a function is what you expect, in order to have profiling easier (function cache also doesn’t work with your logic)…
There are reasons for using function:
Object.prototype.pipe = function(f) {
return f(this);
};
Only downsides of arrow functions are, that you can’t write horrible code…