Reputation: 12712
Here's some code I have:
window.MyNamespace ?= {}
window.MyNamespace.Subnamespace ?= {}
window.MyNamespace.Subnamespace.Subsubnamespace ?= {}
Is there a way to clean this up in a CoffeeScripty way?
Upvotes: 1
Views: 16
Reputation: 3305
The only alternative I can think of, is to use this somewhat obscure syntax:
((window.MyNamespace ?= {}).Subnamespace ?= {}).Subsubnamespace ?= {}
See also this issue which proposes a way to create an object property if it doesn't exist.
Upvotes: 2