0

I have a problem with my syntax.

i want to use this symbol at my inline object

object?.something

but i don't know how to do this with objects that have white space in their name, like:

object?[some thing] // this is wrong
1
  • can't see how thats a duplicate? i want to get the object variable once it's not undefined anymore. Want to know what the inline syntax is for this action when the key has white space in it. Commented Feb 22, 2018 at 15:30

1 Answer 1

2

you can do this :

(object || {})['some thing']
Sign up to request clarification or add additional context in comments.

2 Comments

I think it should be (object || {})['some thing'] (with quotes)
ofcourse hehe, thank you! i use it like (object) ? object : 0. i'll accept your awnser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.