Among the primitive data type, you may have already heard about Symbol. But you're asking yourself what is it? When is it useful? When are they cur...
For further actions, you may consider blocking this person and/or reporting abuse
Great explanation! Another use case for
Symbols
is safely extending prototypes (Array, String, Number, etc.) - I built a library (Metho) that helps to do this kind of thing easily. Check it out if you want to see another waySymbols
can be usedOh thank you for the additional information. I check your library asap :)
In the "same value in iframe" section both return false, what am I doing wrong?
Hello. Do you have some code to share ?
I have made a codesandbox where you can see the behavior: codesandbox.io/s/iframe-example-fo...
Hi, it worked, thanks, I just needed to use load to wait for the iframe to load.
iframe.addEventListener('load', () => {
// do something
});
one question.
why did you write the last example as
class Computer {
constructor() {
this[Symbol.toStringTag] = "Computer";
}
}
and not like
class Computer {
[Symbol.toStringTag] = "Computer";
}
I write like this because if I'm not mistaken the
public class field
will be available in ES2022.Or we currently can use it thanks to babel plugin
@babel/plugin-proposal-class-properties
Great article! Really enjoyed the iterator and class toString methods you presented.
Thank you. Glad you liked it :)
wow. you used some advanced syntax and techniques there. I read about Symbols way back but never used them and neither do people generally know about them as I have seen.
Yep generally people doesn't know about
Symbol
, hoping my article will show that it's useful :)