You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// public methods
var drawLine = function (screen, leftPoint, rightPoint) { ... }
var drawRect = function (screen, topLeft, bottomRight) { ... }
var drawCircle = function (screen, center, radius) { ... }
// private helpers
function bitBlt (screen, ...) { ... }
function resize (screen, ...) { ... }
// public methods
drawLine = function (screen, leftPoint, rightPoint) { ... }
drawRect = function (screen, topLeft, bottomRight) { ... }
drawCircle = function (screen, center, radius) { ... }
// private helpers
function bitBlt (screen, ...) { ... }
function resize (screen, ...) { ... }
})();
or
var DrawModule = (function () {
// public methods
var drawLine = function (screen, leftPoint, rightPoint) { ... }
var drawRect = function (screen, topLeft, bottomRight) { ... }
var drawCircle = function (screen, center, radius) { ... }
In the "The Pause That Refreshes: Rebinding and References" chapter, section modules. Where there's:
var DrawModule = (function () {
return {
drawLine: drawLine,
drawRect: drawRect,
drawCircle: drawCircle
}
// public methods
var drawLine = function (screen, leftPoint, rightPoint) { ... }
var drawRect = function (screen, topLeft, bottomRight) { ... }
var drawCircle = function (screen, center, radius) { ... }
// private helpers
function bitBlt (screen, ...) { ... }
function resize (screen, ...) { ... }
})();
which returns
Object { drawLine=undefined, drawRect=undefined, drawCircle=undefined}
should rather be (based on what I've learned in "function declarations"):
var DrawModule = (function () {
return {
drawLine: drawLine,
drawRect: drawRect,
drawCircle: drawCircle
}
// public methods
drawLine = function (screen, leftPoint, rightPoint) { ... }
drawRect = function (screen, topLeft, bottomRight) { ... }
drawCircle = function (screen, center, radius) { ... }
// private helpers
function bitBlt (screen, ...) { ... }
function resize (screen, ...) { ... }
})();
or
var DrawModule = (function () {
// public methods
var drawLine = function (screen, leftPoint, rightPoint) { ... }
var drawRect = function (screen, topLeft, bottomRight) { ... }
var drawCircle = function (screen, center, radius) { ... }
return {
drawLine: drawLine,
drawRect: drawRect,
drawCircle: drawCircle
}
// private helpers
function bitBlt (screen, ...) { ... }
function resize (screen, ...) { ... }
})();
Otherwise module will return POJO with undefined references before executing function expression.
The text was updated successfully, but these errors were encountered: