As subject. By 'before' I mean before in the file, not in time.
Here's a file
===
$ cat wierd.js
f()
function f(){print('hi') }
f()
function f(){print('ho') }
f()
===
And when I run SpiderMonkey on it
$ js wierd.js
I get - well, what do you think I get?
OK. So I get
===
$ js wierd.js
ho
ho
ho
===
So it seems that SpiderMonkey is picking up the LAST definition of f()
and executing it three times. Not at all what I expected.
I didn't find any relevant information in
I'd like to read about this. Any pointers? In particular, does anyone
know of a JavaScript book that documents this behaviour? And is it
reliably cross-platform?
--
Jonathan
Here's a file
===
$ cat wierd.js
f()
function f(){print('hi') }
f()
function f(){print('ho') }
f()
===
And when I run SpiderMonkey on it
$ js wierd.js
I get - well, what do you think I get?
OK. So I get
===
$ js wierd.js
ho
ho
ho
===
So it seems that SpiderMonkey is picking up the LAST definition of f()
and executing it three times. Not at all what I expected.
I didn't find any relevant information in
I'd like to read about this. Any pointers? In particular, does anyone
know of a JavaScript book that documents this behaviour? And is it
reliably cross-platform?
--
Jonathan
Comment