 <p>The standard Javascript way is to pass an "options" object like</p> <pre><code>info({spacing:15, width:46}); </code></pre> <p>used in the code with</p> <pre><code>function info(options) { var spacing = options.spacing || 0; var width = options.width || "50%"; ... } </code></pre> <p>as missing keys in objects return <code>undefined</code> that is "falsy".</p> <p>Note that passing values that are "falsy" can be problematic with this kind of code... so if this is needed you have to write more sophisticated code like</p> <pre><code>var width = options.hasOwnProperty("width") ? options.width : "50%"; </code></pre> <p>or</p> <pre><code>var width = "width" in options ? options.width : "50%"; </code></pre> <p>depending on if you want to support inherited options or not.</p> <p>Pay also attention that every object in Javascript inherits a <code>constructor</code> property, so don't name an option that way.</p>