Hi,
I was finding some things i read strange and some against the ecmascript specs...
p196
It reads here that the function parameter of replace() takes one argument. It takes m+3 however. See below. In firefox it actually works that way also...
"If replaceValue is a function, then for each matched substring, call the function with the following m + 3 arguments. Argument 1 is the substring that matched. If searchValue is a regular expression, the next m arguments are all of the captures in the MatchResult (see 15.10.2.1). Argument m + 2 is the offset within string where the match occurred, and argument m + 3 is string. The result is a string value derived from the original input by replacing each matched substring with the corresponding return value of the function call, converted to a string if need be." from ecma standard 3rd ed. p102
Further down it says comma needs to be escaped. I use it with success without escaping. On the next page in the you also don't mention it as a metacharacter...
p579-580
Here you talk about a scope tree. however, to my knowledge fn1() could not access sMyLastName. Therefor there would absolutely be no reason to look up the scope chain like you put it. The ecma script standard defines it like this:
"The production FunctionDeclaration : function Identifier ( FormalParameterListopt ) { FunctionBody }
is processed for function declarations as follows:
1. Create a new Function object as specified in 13.2 with parameters specified by FormalParameterList, and body specified by FunctionBody. Pass in the scope chain of the running execution context as the Scope.
2. Create a property of the current variable object (as specified in 10.1.3) with name Identifier and value
Result(1)." ecma standard 3rd ed p71
As far as I'm concerned this would be the scope of the running context where the function is declared, not where it is called. (closures) Obviously it is still cheaper using local variables...
p585-586
In the for loops i is incremented both in the statements as in the for loop. this is probably a mistake
p588
I was just wondering where you got that do while is faster than while, and why is it faster?
Here:
http://home.earthlink.net/~kendrasg/...l#loopflipping Jeff Greenburg seems to find that it do while is usually slower:
Loop flipping is the method of taking a loop that has it's condition evaluated at the top and changing it to evaluate at the bottom. Most of the time this seems to be inferior to a top evaluating loop in JavaScript, but there are times, which I haven't been able to predict, when bottom evaluating seems faster.
So I hope I did not make any mistakes,
curious what you think
greets
ufo