Johannes Baum
Feb 18, 2021

--

That depends on what you mean by "within a key".

JS will only use strings and symbols as keys. But the value behind this can be function.

So

obj[function myFn() {}] = 'myFunction';

will call .toString() on the function you passed and use the stringified version of that function as a key. But the value can be anything.

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

--

--

Johannes Baum
Johannes Baum

Written by Johannes Baum

Creator of GridEngine (https://github.com/Annoraaq/grid-engine) 👾 Software Engineer 🚀 JavaScript/TypeScript

No responses yet

Write a response