In this line of code of an Backbone app:
window.App ?= {}
what does ?=
mean? Is is something like initialization of a Backbone app with empty defaults?
I'm new to Backbone/CoffeeScript and I read that an empty app (in CoffeeScript) would look like:
window.MyApp =
Models: {}
Collections: {}
Views: {}
Routers: {}
initialize: ->
#do stuff
So is the first a shorthand for the second?
It is the existential operator in CoffeeScript and would be (almost) equivalent to this JS
window.App = window.App || {};
It ensures that your App
namespace is defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With