script
elementGuest 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.
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.
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):
There are a variety of software technologies out there for helping you with creating slides. Following are ones that I find intriguing: