2011-06

Equality in JavaScript

[2011-06-15] dev, javascript, jslang
Update 2011-12-02: When is it OK to use == in JavaScript?

There are two operators for comparing values in JavaScript: strict equality === and “normal” (or lenient) equality ==. Many style guides (correctly) tell programmers to avoid lenient equality and always use strict equality. This post explains why.

Tip: use JavaScript as a calculator in Firefox and Chrome

[2011-06-10] browser, firefox, hack, javascript, computers, clientjs, chrome
The following tip allows you to quickly perform calculations via JavaScript in Firefox and Chrome. Many people use Google for this purpose, but this tip even works if your computer is offline.

Implementing bookmarklets in JavaScript

[2011-06-08] bookmarklet, dev, javascript, clientjs
Bookmarklets are little plugins for your browsers: JavaScript programs packed into javascript: URLs that you add to your bookmarks and start by clicking on them. They perform an operation on the currently open web page such as submitting it to Twitter. There are even bookmarklets that transform the current web page, for example, to add icons that, when clicked, add an event to Google Calendar. A separate post explains what bookmarklets are in more detail. This post tells you how to implement bookmarklets. It presents techniques, tools, and patterns for doing so.

JavaScript’s with statement and why it’s deprecated

[2011-06-01] dev, javascript, jslang
This post explains how the with statement works in JavaScript and why its use is discouraged.

2011-05

The void operator in JavaScript

[2011-05-26] dev, javascript, jslang

Syntax.

void <expr>

evaluates expr and returns undefined.

Bookmarklet: copy a link for Twitter and editors

[2011-05-21] bookmarklet, dev, hack, blogging
Update 2011-09-27: Automatically remove parts of the title, add a Twitter name, add a hashtag.

Problem: You have found an interesting web page and would like to copy its link, for use with Twitter or an editor. That means you need to perform several steps: First, you copy the URL. Second, you go back to copy the title (which might be tricky to get at). Third, you construct the link from the copied pieces.

Web gaming technologies: Angry Birds’ cross-compiled Java versus native JavaScript

[2011-05-21] angry birds, dev, gaming, webdev, java
After it became clear that Angry Birds was basically a true webapp with only a little Flash to overcome the limitations of web-based audio [1], more information came to light regarding the technology it is based on [2].

Tip: load source from a file in the Node.js shell

[2011-05-18] dev, nodejs, repl, javascript, jslang
Node.js is really handy as an interactive shell for JavaScript. To load source code from a file, you must create a module. This post explains how.

Making it easier to reply to email digests

[2011-05-17] dev, hack
Mailing lists are still a common way of communicating in teams. If the volume is high, a convenient option is to receive a digest that delivers several sent messages in a single email.

Automatic semicolon insertion in JavaScript

[2011-05-15] dev, javascript, jslang
Update 2011-11-11: What JavaScript would be like with significant newlines

In JavaScript, automatic semicolon insertion allows one to omit a semicolon at the end of a line. While you always should write semicolons, knowing how JavaScript handles their omission is important knowledge, because it helps you understand code without semicolons and because it has effects even in code with semicolons.