I've got 2 different ways to code the World function. The first is an example from Cucumber.js's website. This is extending their existing World object basically. And the second example commented out is me taking that first example code and getting rid of that world variable and passing nothing in the callback. My code works too.
Question: Why would they be sending a variable like this in a callback? Is there any advantage to that? Because in my example, I'm already extending the existing World object by simply setting properties in my example.
I'm sorta still new to callbacks...
"use strict";
var hooks = require('../support/before_hooks.js');
var zombie = require('zombie');
// their example
var World = function World(callback) {
var browser = new zombie();
var world = {
browser: browser,
visit: function(url, callback) {
this.browser.visit(url, callback);
}
};
callback(world);
};
// my example
//var World = function World(callback) {
// this.browser = new zombie();
// this.visit = function(url, callback) {
// this.browser.visit(url, callback);
// };
// callback();
//};
module.exports.World = World;