I'm Learning JavaScript!
I’ve finally learning about JavaScript after listening to the Google TechTalk, Doug Crockford: JavaScript: The Good Parts . Here are my first couple of test scripts. I’m using Rhino for runtime and JSLint (obviously) to check the code. Through these code examples I learnt a lot, about the tools, the language and how to integrate it to do useful stuff. It is early days, but I can see JavaScript being a valuable instrument in my tool box! Example 1 - Random Digits Here is a simple command line script to produce random numbers from 0 to 9. The first two lines are pragmas passed to JSLint. /*jslint indent: 4, maxlen: 80, rhino: true */ /*global java*/ // returns a semi-random digit between 0 and 9 function getRandomDigit() { 'use strict' ; return Math.round(Math.random() * 9); } // example using array var digitName = ( function () { 'use strict' ; var names = [ 'zero' , 'one' , 'two' , 'three' , ...