T
Thomas 'PointedEars' Lahn
Andrea said:var o = {};
with(o){
(function(__proto__){
return function () {
__proto__.a = 123;
};
}({})).call(o);
}
That is _not_ the same code that I had commented on, and it is
unnecessarily complex by comparison, but I'll bite.
where is exactly the disaster?
If either Variable Object had a `__proto__' property that is not read-only,
subsequent accesses to `a' from within the function would be successful,
because when a function execution context is entered, a VO is created and
augmented with properties named for each named argument and each variable.
In particular, subsequent accesses to `o' would not target the global
variable `o' but the property `o' of the object referred to by `__proto__'
if it had one.
This would be the scope chain (horizontal) and prototype chains (vertical)
with regard to the returned function's execution context:
(7) (5) (3) Ident. res.
VO (Global Object) <--- o <--- VO (local) <--- VO (local) <----------
| | | | (1)
| (8) (6) | (4) | Ident. res. | (2)
| impl.- v v v
`----------> Object.prototype __proto__ [[Prototype]]
dependent
By comparison, your original code, which I had commented on, --
-- would create the following scope chain and prototype chains then:
(7) (5) (3) Ident. res.
VO (Global Object) <--- o <--- VO (local) <--- VO (local) <----------
| | | | (1)
| (8) (6) | (4) | Ident. res. | (2)
| impl.- v v v
`----------> Object.prototype [[Prototype]] __proto__
dependent
So you see that your forging your code here does not make much of a
difference with regard to the situation described above.
for a function created to test an argument? it was NOT a generic
funciton, it was a closure with a specific aim
An aim missed at that. Your introducting `with' here also does not make
sense. `with' appends the object referred to by its parameter to the
*front* of the scope chain; that is irrelevant with regard to the VO of
either function execution context.
example please? following same logic I have already used?
An example of what? (You have only quoted a part of the statement.)
In order to save what?
Memory. (Can't you read?)
Do you know what is my current job?
No. (Is it relevant?)
Can you enlighten us how that WRONG check could save memory for mobiles?
Can you reword this question so that it make sense?
And please provide a list of mobile devices without instanceof support,
thanks, I will tell you how important JavaScript is for these devices.
I have no list, but I have read here from people I trust they know what
they are saying and doing (so not you) that there are relevant mobile
devices that do not implement all features of ES 3 to save memory.
PointedEars