A JavaScript Module Manager That Fits in a Tweet
bfontaine.net
bfontaine.net
No, the magic in JavaScript land right now is being able to take the CommonJS, AMD, or ES6 module spec and have that be the basis for JavaScript _bundling_ and _source code transformation_. Systems like Webpack and Browserify can perform these important functions. The magic is the plugin ecosystems that assemble around your modules to form your software project's build, test, and runtime systems.
The magic is that your JavaScript modules can be isomorphic and bundled to be delivered to and run identically on the web browser just the same as it can run on a Node.JS container. The magic is that IDE's now can grok these module specs and construct a type library - essentially treating the loosey goosey JavaScript language like it had static types. Employing JSDoc comments across your entire codebase is how you give hints to the IDE about parameter types, what can be nullable or optional, etc. You can essentially rig up a statically typed language out of modules and JSDoc comments in modern IDE's like IntelliJ/WebStorm.
JavaScript ES3/ES5 is a crappy toy language, ES6/ES2015 is somewhat less crappy, but still backwards crappatible. It's these modern tools and libraries that all agree on what constitutes a module that make JavaScript a joy to work with and very, very productive.
That really depends on how you make less code. Transforming an if condition in a ternary operator could make the code much harder maintain, therefore bring more bugs. This is one example from several cases.
Sometimes a longer code means a code more readable.
I like the ternary operator more than if, but only because if is a statement in JavaScript.
Judicious, simple, and straightforward use of the ternary operator looks nothing like that.
This is a great read on why that's the case: http://www.joelonsoftware.com/articles/fog0000000069.html
We use this in our production apps.
var object = { thing: {}, otherthing: function() { console.log("I need", this.thing): } };
Just minify all your code into one file people!