Javascript notes
From Reboil
Baltakateiʼs notes for writing Javascript.
Stats
Recipes
Set the background to a color based upon date. Runs once due to the trailing () after the function is defined. For a more detailed exploration of this idea, see this example.
<script defer>
(function setBgFromEpoch(){
const hex = Math.floor(Date.now() / 1000).toString(16).slice(0, 6);
console.log('hex =', hex, 'ISO =', new Date().toISOString());
document.body.style.backgroundColor = `#${hex}`;
})();
</script>
History
See also
External links
References
Footnotes