Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computed Property Key #11

Open
mlajtos opened this issue Oct 9, 2018 · 0 comments
Open

Computed Property Key #11

mlajtos opened this issue Oct 9, 2018 · 0 comments

Comments

@mlajtos
Copy link
Owner

mlajtos commented Oct 9, 2018

In JS, you can use computed property name like this:

const key = "age"
const mu = {
    [key]: 47
}

In L1, you should be able to do this via string interpolation:

key: "age"
mu: {
    "$(key)": 47
}

This means that object should allow strings as prop keys, which is good since it will be closer to JSON.


Another way is using just parens, which looks really clean:

key: "age"
mu: {
    (key): 47
}

How to define computed symbol key props...?

key: "age"
mu: {
    (#(key)): 47  ; ugly
    (# key): 47  ; hmm
    #(key): 47 ; hmm2
    (Symbol key): 47 ; via function call (compatible with "(# key)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant