Joined September 2015
·

gerardsans

London ☂
·
·

Posted to JavaScript - Using Namespaces over 1 year ago

Only if you could... For the moment ES6 modules will be transpiled to ES5 using a similar approach. Look into the transpiled code and be shocked =)

I created a little test and it worked fine for me. I believe your issue is in your data and not in the approach shown here.

It seems is browser related as shows DOM manipulation. Is pointing to attributes. Maybe it doesn't like data-content attribute?

You could use ngSwitch too but it wouldn't be a dynamic template then.

Is this improving page loading at all? Why not use predefined sizes that can be stored and cached both on the client/server? It seems you are doing a lot of backend image processing which takes valuable server side time and resources. Besides dinamically generated images can't be cached by browser/web server unless you add dimensions to the url. Am I missing something?

Posted to How do you check undefined ? over 1 year ago

@analog-nico after checking the gist everything looks fine. #1 and #2 are not really uses of "undefined" but a parameter using a JavaScript built-in object name which is not recommended but possible. You could also use parameters names like window, document or location with similar results.

Posted to JavaScript - Module pattern over 1 year ago

Thanks for giving your opinion.

This protip is about the Module Pattern and not against AMD. AMD solves more complex scenarios. Please follow links for more information on AMD.

Posted to JavaScript - Module pattern over 1 year ago

I see. That's what it seems to me. I did not invented the Module Pattern. You don't like it. It's fine. I believe is useful and backed up from many sources. I really don't understand why all this fuss. Use whatever you like. Even better add your own pro tip about it. These comments add no value and only makes everybody waste their time. Classic trolling in my book.

Posted to JavaScript - Module pattern over 1 year ago

Why would I need to copy the code or replace it? It looks the same because is the SAME pattern. I'm sharing the code to help other developers. Best wishes. Have a lovely day.

Posted to JavaScript - Module pattern over 1 year ago

You should stop trolling. Some other sources where you can see the very SAME pattern being used.

"Learning JavaScript Design Patterns", the Module Pattern, Addy Osmani 2014

"Mastering the Module Pattern", Todd Motto

Posted to JavaScript Constructors over 1 year ago

These are examples of different notations for constructors.

Posted to JavaScript *this* keyword over 1 year ago

@longlivechief maybe you could write your own pro tip on the topic?

Posted to JavaScript *this* keyword over 1 year ago

@kfwerf Bind is not necessary. That is exactly what the first parameter does on call and apply. Just replace on my example Fn.call(this,2,3) or Fn.apply(this,[2,3]).

Code should be self explanatory. Only the last code makes use of a closure and fixes the initial problem. Anything else look the demo code. You don't need to agree.

Posted to JavaScript - Module pattern over 1 year ago

AMD says it all async module definition. Is that what you want? You probably don't need it.

Posted to JavaScript - Module pattern over 1 year ago

I recommend you reading Mozilla docs on closures. Private members are achieved by closures. Which is the base of encapsulation.

Posted to JavaScript - Module pattern over 1 year ago

If you just want that you don't really need them.

Posted to JavaScript - Module pattern over 1 year ago

Thanks for your comments. These libraries are not of my interest for what I wanted to show.

Posted to JavaScript - Using Namespaces over 1 year ago

Scope isolation is related but not exactly the same concept as namespaces in JavaScript. I will write about JavaScript Modules and Sandboxing in another article.

Thanks! Included now.

Posted to JavaScript Constructors over 1 year ago

Some will be surprised here. link

var stranger = 2;
var Order = (function() {
   return function(id) {
     this.id = id;
     this.value = stranger;
     stranger = 3;
   }
})();
var order = new Order(1);
console.log(order.id); // 1
console.log(order.value); // 2
console.log(stranger); // 3
Posted to JavaScript Constructors over 1 year ago

I see. I will write about JavaScript modularisation soon. As an example for a constructor is a little overkill though. Thanks!

Posted to Coderwall - Markdown Cheat Sheet over 1 year ago

Code shows really ugly compared to other state-of-the-art code visualisers. Any chance we will be able to integrate jsfiddle, jsbin like code snippets?

Bug. Your demo fails when you mark items as completed incrementing active items instead of completed.

Posted to AngularJs Directives For Beginners over 1 year ago

How is the last link related to anything?

Achievements
1 Karma
186,220 Total ProTip Views
Interests & Skills