--

It depends on if you have the type/interface defined with specific keys (e.g. type Foo = { bar: string; baz: string }) or generic keys (e.g. type Bar = { [key: string]: string }). In the former case, you wouldn't have to worry, because the key "toString" is not defined in the type. In the latter case, "toString" is a valid possible key.

*However*, even without TypeScript, this is an edge case at best, and a poor argument for using Map vs plain objects. See the comment from Hajime Yamasaki Vukelic above as to why.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Aurelia Fenderson-Peters
Aurelia Fenderson-Peters

Written by Aurelia Fenderson-Peters

20+ years writing code of various sorts. Full of trans magic.

No responses yet

Write a response