Simple HTML (string) to DocumentFragment (usable Node)

JavaScript – recursively construct (provide) a namespace

Use like:

POC: http://jsfiddle.net/moagrius/4L31fxoy/1/

JavaScript – get index of child element

POC: http://jsfiddle.net/moagrius/kamcb6gr/

Change content of before or after psuedo element with JavaScript

Set the content to an attribute, and change the attribute with script.

POC: http://jsfiddle.net/moagrius/9vt04bch/

Simple JavaScript to Query Parameter Serializer

POC: http://jsfiddle.net/moagrius/vftL6fvh/

Seriously Simple JavaScript Cookie Management

Here’s the basic idea of one way to manage cookies with JavaScript. As always, there are more robust libraries available, but here’s the upshot:

POC: http://jsfiddle.net/moagrius/kwctsnyq/

Why does indexOf return -1

Both Array.prototype.indexOf and String.prototype.indexOf (as well as all their counterparts in other languages) return -1 when a match is not found. This can seem less-than-obvious to new learners. I often use this example to illustrate why:

Simple requestAnimationFrame polyfill

While there are definitely better versions, as always I’m concerned with the fundamental function – and for requestAnimationFrame it’s pretty straightforward:

Basic JavaScript Tasks (vanilla, framework agnostic)

Create a reference

Create a function

Create an array

Create an object

Assign properties to an object

Iterate through an array

Iterate over an object

Get a reference to an element

Get a reference to a collection of elements

Modify an element’s style

Create an […]

JavaScript – get window reference from element