Joined May 2011
·

Benjamín Eidelman

Software Engineer at Orchard Mile
·
Buenos Aires, Argentina
·
·
·

Posted to JavaScript - Module pattern over 1 year ago

I guess @longlivechief said it all, I just wanted to clarify my comment is not trolling, more like the opposite, I was trying to prevent future readers from making the same mistakes I did in the past (I've used this module pattern, then AMD (require.js), and then CommonJS (browserify).
A response expected in any mature online community is: you get comments that try to correct/improve on the subject, read a little about them and update your article if appropriate.
Learning is a process that requires a lot of humbleness, and I like to think the biggest purpose of this tips is help the future readers. Regards.

Posted to JavaScript - Using Namespaces over 1 year ago

again, this is much better solved using a real module system like CommonJS, AMD or ES6 modules.

Posted to JavaScript - Module pattern over 1 year ago

Honestly this tip seems kinda outdated, as nowadays we have these module systems:

  • CommonJS (used by node.js server-side, that can be brought to browsers using browserify bundling tool)

  • AMD (Async Module Definition, supported by tools like RequireJS)

  • UMD (Universal Module Defintion, a syntax that supports CommonJS, AMD, and vanilla browser globals, browserify can produce UMD modules)

  • EcmaScript6 modules, probably the most elegant (and it's the upcoming standard), the downside is for current browsers it requires a transpilation step, eg. using Traceur (partial), or browserify with an ES6 plugin (probably the best option at the moment of this writing)

Posted to Vagrantfile. Set memory and CPU over 1 year ago

now you can use these shortcuts:
v.cpus = 4 v.memory = 2048

Posted to Easily Extend Javascript Prototypes over 1 year ago

Just to add on this, if you happen to be on node.js there's already a builtin function for this (util.inherits): http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor

Posted to Avoid using typeof to test undefined over 1 year ago

well if you want to support ie8 (please don't!! :)), if your code works fine on modern browsers with strict mode, you can still have errors on ie8, even worse, you can get errors that only show up on ie8, so testing gets harder.
Of course though if someone redefines undefined should go to prison for the rest of his/er life :)

Posted to Avoid using typeof to test undefined over 1 year ago

what happens if undefined is redefined in a script without strict mode, couldn't that affect undefined on my scrict-mode block?

Posted to Avoid using typeof to test undefined over 1 year ago

unless you really need to support old browsers, ie. IE8

I've done some experiments with both (though not real world experience), I found Ember.js to be often excessively sophisticated, it's the kind of frameworks that takes all decisions for you. It's very complete (and heavy, though for a JS Mvc app I think is not terrible) it comes with much more out-of-the box, but IMHO I think is bloated with complexity, and unnecessary levels of abstractions.

Angular.js seems more natural and straightforward to me. The approach to most problems is very simple, and that's a big cumpliment. eg. Angular doesn't try to abstract html (as Ember), but embrace it.
the way databinding is solved in angular is brilliant and simple, and it has just the necessary abstractions to structure your app, a module system with support for dependency injection.

thanks! I didn't knew document.createElement had that effects, thanks a lot for your explanation.

interesting, could you explain a big how this would work?

@Licenser all comments seem to indicate what you said, it's not a myth, actually it's not just 2 libs, there are many more libs out there to avoid it, and they follow different approaches.
Something I'd say is that if you find yourself in callback hell to often, you might be trying to write a lot in 1 function.

Posted to cross domain iframe communication over 1 year ago

I opensourced a small script to do cross-domain requests using a hidden iframe using this same mechanism: https://github.com/benjamine/FrameProxy

Achievements
152 Karma
0 Total ProTip Views