How to document a string type in jsdoc with limited possible values

As of late 2014 in jsdoc3 you have the possibility to write: /** * @param {(‘rect’|’circle’|’ellipse’)} shapeType – The allowed type of the shape */ Shape.prototype.getType = function (shapeType) { return this.type; }; Of course this will not be as reusable as a dedicated enum but in many cases a dummy enum is an overkill … Read more

Does it make sense to minify code used in NodeJS?

Minification can improve performance. Node’s V8 optimizing compiler inlines functions according to some heuristics. Minification influences these heuristics. This can cause inlining of previously not inlined functions. Since inlined functions generally perform faster, this can lead to performance improvements. ###Node 9.0+ / V8 6.2+ (Turbofan) – minor performance improvements If the function’s unoptimized bytecode size … Read more

How do I split my javascript into modules using Google’s Closure Compiler?

Closure-compiler’s ability to create multiple output files provides a powerful tool to separate input files into distinct output chunks. It is designed such that different chunks can be loaded at differing times depending on the features required. There are multiple compiler flags pertaining to chunks. Each use of the –chunk flag describes an output file … Read more

difference between “void 0 ” and “undefined”

From MDN: The void operator evaluates the given expression and then returns undefined. This operator allows inserting expressions that produce side effects into places where an expression that evaluates to undefined is desired. The void operator is often used merely to obtain the undefined primitive value, usually using “void(0)” (which is equivalent to “void 0“). … Read more