A working demonstration both of a J(ava)Script Command-Line parser, and of object-oriented programming in JavaScript.
This script is a useful set of objects to solve a common problem -
parsing the command-line passed to console scripts. However, it is also a working
demonstration of object inheritance in JavaScript, based on the techniques explained in an excellent
tutorial:
Object Hierarchy And Inheritance In Javascript
Although it is not intended to explain object inheritance here, as a non-trivial working implementation of it, this script may prove a useful guide.
You can demonstrate the script online here by entering, say, ? to get help, and then following the help given to work out a valid command-line. To download the script, <Right-Click> CmdLine.js and choose Save As.
Updated | Description |
---|---|
13/06/2010 | v1.1 - Safer Array for() loops if the Array.prototype is altered. |
09/12/2009 | Created v1. |