Duplicated Argument Names
Oftentimes we override or monkey patch functions and, in many cases, there are arguments we don't care too much about. A common practice for those arguments is using _
for argument names -- it's a generally accepted and known practice for "this isn't important". I started thinking about multiple useless arguments and if you could use the same name for the sake of minification -- you can.
So what happens when you use the same argument name more than once? An error? Uses the first value? The last value? Let's have a look:
function myFunc(_, _, _) {
console.log("_: ", _);
}
myFunc(1, 2, 3);
// >> 3
The duplicated argument is given the value of the last provided argument. If, however, "use strict"
is used, an error will be thrown.
For some reason I expected an error when using an argument name more than once. On the other end, you can change argument values so I shouldn't be surprised. Anyway, happy coding!
![JavaScript Promise API]()
While synchronous code is easier to follow and debug, async is generally better for performance and flexibility. Why "hold up the show" when you can trigger numerous requests at once and then handle them when each is ready? Promises are becoming a big part of the JavaScript world...
![Facebook Open Graph META Tags]()
It's no secret that Facebook has become a major traffic driver for all types of websites. Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly. And of course there are Facebook "Like" and "Recommend" widgets on every website. One...
![JavaScript Copy to Clipboard]()
"Copy to clipboard" functionality is something we all use dozens of times daily but the client side API around it has always been lacking; some older APIs and browser implementations required a scary "are you sure?"-style dialog before the content would be copied to clipboard -- not great for...
![Comment Preview Using MooTools]()
Comment previewing is an awesome addition to any blog. I've seen really simple comment previewing and some really complex comment previewing. The following is a tutorial on creating very basic comment previewing using MooTools.
The XHTML
You can set up your XHTML any way you'd like.