Avoid function hoisting, but still define a name.
npm install named-function``sh`
npm install --save named-function
with named-function
-------------------
CoffeeScript:
`CoffeeScript`
NamedFunction = require "named-function"
Rectangle = NamedFunction "Rectangle", (@width, @height) ->
JavaScript:
`JavaScript`
var NamedFunction = require("named-function")
var Rectangle = NamedFunction("Rectangle", function (width, height) {
this.width = width
this.height = height
})
without named-function
----------------------
CoffeeScript:
`CoffeeScript`Impossible in CoffeeScript.
JavaScript:
`JavaScript``
var Rectangle = (function () {
return function Rectangle (width, height) {
this.width = width
this.height = height
}
})()