9 ms·
Also, if he ever needs to check if a variable is a number, there is another one-line-of-JS project on npm that does just that!
by carterehsmith 11y ago
Also, if he ever needs to check if a variable is a number, there is another one-line-of-JS project on npm that does just that!
- franciscop 11y agoBut it isn't one line: var clone = require('clone'); module.exports = function(options, defaults) { options = options || {}; Object.keys(defaults).forEach(function(key) { if (typeof options[key] === 'undefined') { options[key] = clone(defaults[key]); } }); return options; }; Besides the tests and the fact that someone is maintaining it. It's not much, but it's code that doesn't have to be maintained by you