- Printed at
- Up to date at
- Studying time
- 1min
I’ve simply learn Exploring JavaScript Symbols, and it is fairly good. It features a tiny JavaScript nugget that I wasn’t very conscious of.
JS symbols are an underrated language function that I in all probability ought to use for extra issues. And not to mention the properly nerdy well-known symbols that provide help to to actually perceive how JavaScript works underneath the hood.
Considered one of these image use instances is hiding properties in a great outdated JavaScript objects.
const lastTouched = Image('lastTouched');
const file = {
title: 'schnitzel'
[lastTouched]: 'proper now',
};
console.log(file);
console.log(file[lastTouched]);
Object.keys(file);
Object.entries(file);
Object.values(file);
JSON.stringify(file);
for (let key in file) { console.log(key); }
An emblem property will not seem in Object
and associates, might be ignored in JSON
and is safely hidden in for-in
loops. Fairly good!
If you happen to loved this text…
Be a part of 5.5k readers and study one thing new each week with Net Weekly.