2014-05

Identifying the current script element

[2014-05-04] guest, rodney, dev, javascript, clientjs

Guest blog post by Rodney Rehm

You may find yourself in a situation requiring you to know the DOM context of the JavaScript that is currently executing. The DOM context of a running JavaScript is the <script> element that caused the JavaScript to be executed in the first place. With HTML5 the WhatWG introduced document.currentScript, which this article will use to explain simple techniques to make use of DOM context.

JavaScript’s this: how it works, where it can trip you up

[2014-05-01] dev, javascript, jslang
[2017-12-06] Follow-up post: “A different way of understanding `this` in JavaScript


In JavaScript, the special variable this is relatively complicated, because it is available everywhere, not just in object-oriented settings. This blog post explains how this works and where it can cause problems, concluding with best practices.

2014-04

The interoperability of Web Component polyfills

[2014-04-25] dev, html5, javascript, webcomponents, webdev

Handling required parameters in ECMAScript 6

[2014-04-23] esnext, dev, javascript
In ECMAScript 5, you have a few options for ensuring that a required parameter has been provided, all of which are somewhat brittle and inelegant:
    function foo(mustBeProvided) {
        if (arguments.length < 1) throw new Error(...)
        if (! (0 in arguments)) ...
        if (mustBeProvided === undefined) ...
    }
In ECMAScript 6, you can (ab)use default parameter values to achieve more concise code (credit: idea by Allen Wirfs-Brock):

The maximum call stack size

[2014-04-10] esnext, dev, javascript
Are you curious how many recursive calls you can make on your JavaScript engine?

In search of the perfect technology for slides

[2014-04-09] presenting, computers
I many cases, if you are presenting in front of an audience, you will create slides, visual material of some kind. I’m a very visual person myself and learn much better if I can read in addition to listen. Slides are also helpful when you lose attention for a few seconds.

There are a variety of software technologies out there for helping you with creating slides. Following are ones that I find intriguing:

Making checkbox labels clickable via <label>

[2014-04-02] dev, html
The <label> element has been around for a while, but I still don’t see enough websites use it. In lets you make labels of checkboxes and radio buttons clickable.

2014-03

reduce() and array indices

[2014-03-20] dev, javascript, jslang
This blog post explains how the index works that Array.prototype.reduce() passes to its callback.

2014-02

Taking a break

[2014-02-20] 2ality

JavaScript time values: dates as milliseconds since 1970-01-01

[2014-02-14] dev, javascript, jslang
This blog post explains how JavaScript dates are stored internally as time values, milliseconds since 1970-01-01.