T
Thomas 'PointedEars' Lahn
kangax said:Thomas said:kangax said:Thomas 'PointedEars' Lahn wrote:
for (var i = 1; i < len; i++)
{
var
p = arguments,
p_is_Array = (i === len - 1 && jsx.object.isArray(p)),
origP = p;
[...]
}
Did I miss something?
[...] avoid resolving `jsx.object.isArray` over and over,
Will do (as done elsewhere). However, it would have to be v.isArray(...)
in any case, or extensive rewrites might be needed if I change how
jsx.object.isArray() gets to the jsx.object.isInstanceOf() that it calls.
Hmm. I was thinking of something like `var isArray =
jsx.object.isArray`. So I take it that `isArray` is using `this` to
reference `jsx.object`?
It might, in the future, when the global `isArray' variable (not that here)
were no longer needed.
If so, then introducing extra variable to go
from double property access to single doesn't seem justified.
It is not just the property access but also the identifier resolution along
the scope chain. The additional steps, and unreliability avoided, by using
function ...(...)
{
var foo = bar.baz;
for (...)
{
foo.bla
}
}
instead of
function ...(...)
{
for (...)
{
bar.baz.bla
}
}
are worth closer inspection.
You're right. However, I would submit that there is still a differenceAs far as type converting host objects (not methods!), didn't we just
have a conversation about it where you said that it should be safe to do so?
[...]
<http://groups.google.com/group/comp.lang.javascript/msg/4df3cf9b5a7bd60f>
Or am I missing something?
Yes, I was talking about return values of standardized methods there.
I'm pretty sure we were talking about `lastChild`/`firstChild` as an
operand in `if`/`while` expression (when "emptying" element contents).
between a property of a host object that must strictly follow specification,
and a host-defined property of the global object or a property of a host
object, that does not strictly follows implementation (for historical reasons).
So `Node::firstChild` is part of a DOM standard, but `Window::document`
is not (because global `window` is not part of a standard). Am I
understanding you correctly?
Partially.
It is not the value but the existence of the property that matters here.
Just to make things clear, I am interested in your opinion about
boolean- type conversion of host objects (not methods). You mentioned
that it is safe to type convert `<nodeRef>.firstChild/lastChild`.
No, I said that I could not see a good reason why it should be unsafe.
Now I'm trying to figure out whether it is safe to type-convert other host
objects, such as `document`;
e.g. - `if (<global object>.window.document) { ... }`.
The specified arbitrariness of host object's [[Get]] implementations
suggests that it is probably is not safe.
I usually use `null`.
I would rather throw an exception instead. `is*' methods are not supposed
to return non-booleans; and if you replied that types would not matter, my
reply would be why `false' would not suffice then.
Actually, in a conforming implementation of ECMAScript, Edition 3, it is not
that inefficient. While the initialization of the variable happens on each
call indeed, the creation of the RegExp object would not (section 7.8.5).
ECMAScript Edition 3.5 Final Draft, section 7.8.5, suggests that this
behavior might change. But as for now, only if the runtime of the
initialization turned out to be significant, then another closure might be
in order.
^^^^^^^^^^^^^^^^^^^^^^^^I would use a closure (into which things like `rxUnknown` and `rxMethod`
can go), and if closure is out of the question, use function object
itself, but access it via identifier, not `arguments.callee`.
Read again.
PointedEars