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

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