Bracket and dot notation in compiled CoffeeScript

I have this piece of code in a Node/Express app:

app.use "/static","#{__dirname}/public")
app.use "/static", express.static("#{__dirname}/public")

It compiles to this:

  • How to generate global, named javascript functions in coffeescript, for Google Apps Script
  • not emitting/receiving events while using namespaces
  • Angular - Unknown Provider from Provider
  • Is it possible to define an infix function?
  • Backbone-relational: Association key won't work unless it's the same as the foreign key
  • Rails and Stripe Payments
  • app.use("/static","" + __dirname + "/public"));
    app.use("/static", express["static"]("" + __dirname + "/public"));

    By curiosity, I am wondering: why is the dot notation used for the first call and the bracket notation for the second call?

  • Compiling some CoffeeScript files on save
  • Why is this sinon spy not being called when I run this test?
  • Improve unobtrusive javascript (and possibly use CoffeeScript) in a Rails application
  • Backbone.js click event doesn't work with touch
  • Open Source Node.js (and Express) projects
  • Reading a local file with Coffeescript
  • 3 Solutions collect form web for “Bracket and dot notation in compiled CoffeeScript”

    Because static is reserved in ES3. (not anymore in ES5).

    Because static is a reserved word in Javascript prior to EcmaScript 5 .

    Some browsers might throw an error if it is used as an object property with the object.word syntax .

    object['word'] ensure no error will be thrown.

    static is a reserved word (reserved for future use as a keyword) in javascript.

    You can see a list of reserved words here:

    For example, compiles to x["in"], because in is also a reserved word.