This post describes how to do a limited version of operator overloading in JavaScript.
With the technique described here, you’ll be able to implement a type StringBuilder that can be used as follows:
var sb = new StringBuilder();
sb << add("abc") << add("def");
And a type Point that can be used as follows:
var p = new Point();
p._ = new Point(1, 2) + new Point(3, 4) + new Point(5, 6);
p._ = new Point(1, 2) * new Point(3, 4) * new Point(5, 6);
Update 2012-08-21: All posts about shell scripting via Node.js have the label “jsshell”.
Do you know JavaScript and want to write a shell script? Then you should give Node.js a try. It is easy to install and shell scripts are a great way to get to know it. This post explains the basics.
Tweets marked with the hashtag #MovieLinesInCode express a movie line or title in programming language code.
This post gives some examples in JavaScript; most of them are paraphrased from the blog post “Best of #MovieLinesInCode” by Arialdo Martini [link via Michael Haszprunar].
Update 2013-04-09: now simulates the approach of the ECMAScript 6 specification draft (search for "HomeObject" to find the relevant parts).
This post examines how super-references work in JavaScript and how they will be simplified by ECMAScript 6. To understand this post, it helps to be familiar with JavaScript inheritance. If you are not, consult [2].