Message from JavaScript discussions

August 2017

— Keke

— 

Is this a good way to make something work in both node and browser?

if (typeof module === "undefined") {

  var module = { exports: null };

}

var myNamespace = module.exports = (function () {

    ...

— 

(function (global) {
// Module code
global.myThingy = ...
})(typeof module !== undefined
? module.exports
: window)

Message permanent page

— Oh hey haha, thank you

— I wound up doing something similar

— Hey i'm new here needed some help with thing

— So i have this datastructure

var list = { value: 0,
rest: { value: 1,
rest: null
}
};

— And i want to add new elements at end of this list

— Within rest?

— The innermost one?

— Yes within innermost rest

— I'm able to do that using mutability of list object