I am sure you know Javascript. Or maybe you don't. Or maybe you want to play with it - then download Rhino from Mozilla - it is an interactive Javascript interpreter (to run it, do this:
This code will duly print
How about this:( Read more... )
And the answer is... "
java -jar js.jar
. Rhino's version of Javascript has print(message) and load(filename) functions, but does not have alert(message) - so below I will use print() insteead of the usual alert()
var obj = new Object()
obj.myname = "John Walker"
var my = "my"
var name = "name"
print(obj[my + name])
This code will duly print
"John Walker"
.How about this:( Read more... )
var x = new Object()
x.a = 2
var y = new Object()
y.a = "The A of Y"
y.f = function(param) {
var self = this
param.f = function(arg) { print(self.a + arg + this.a) }
}
y.f(x)
x.f(" is not ")
And the answer is... "
The A of Y is not 2
"