VK wrote:
Failing to attribute your quotes again?
>The most significant, potential difference between the two
pairs is that function objects created via the Function
constructor function may only ever have the global object
in their scope chain.
You probably mean "may only have Global object as current
object" (what [this] points to).
That is extremely unlikely as Mike knows what he is talking about and so
would not make a false statement, and certainly not using one using such
vague terminology.
As a function created with the Function constructor can be used in the
same way as any other function object, and so assigned to properties of
objects, properties of constructor's prototypes, event handling
attributes and so on, the - this - keyword used within such a function
can refer to all sorts of objects.
That is true except overloaded calls like
FunctionObject. call(context) and
FunctionObject. apply(context, args)
No, what you have just written is just false.
A nitpick, I know - but can I do it once? :-)
You can nit-pick, but you look a fool in the attempt because you don't
know what you are talking about.
For the default object the context can be set to anything
by say new Function('arg1' , 'arg2', "with(ObjName){ ...}");
That will still not put any object other than the global object onto the
function's scope chain, only onto the scope chain of the execution
context used when the function is executed.
That is really special in function instances created over
new Function() is that body argument is casted to string
first and then re-evaluated on each call.
It is hardly unusual for javascript's native functions/constructors to
type-convert their arguments into a required type. It is also not
particularly "special", in the sense of needing any attention being drawn
to, as you would be hard pressed to find any documentation that suggested
using anything but a string as the function body argument.
That is the reason you cannot store
directly current [this] value in new Function.
That does not make sense. What is "store directly current [this] value in
new Function" supposed to mean? In what sense can you "store" any value,
let alone a - this - value, "in" any function (beyond assigning values as
named properties of function objects)?
Are you making a confused stab at referring to specific object instances
through the scope chain of function objects? The ability to do that in a
function object resulting form a function expression/declaration and not
in a function created with the function constructor has nothing to do
with the constructor taking string arguments, it is because " function
objects created via the Function constructor function may only ever have
the global object in their scope chain".
>What is it supposed to teach me or
anyone else? How does it help someone understand how
functions behave, or the behavioural differences between
function expressions and declarations? My suspicion is
that it's just an irrelevance.
As I said before, I wanted to mention that
You never actually answer the questions you are asked, do you. You where
asked to explain what you expected to be learnt from all the URLs you
posted.
That you can never answer these questions makes it very obvious that you
don't know what you are talking about. You may try to hide behind
misdirection to the irrelevant, but you are fooling nobody but yourself.
function f(){}
obj.method = f;
and
obj.method = function(){}
do not differ anyhow in the "degree of ownership" between
obj and its method.
You mean that in a language where there is no "ownership" the degree of
absence of ownership is not influenced by how code is written? A rather
pointless thing to be trying to point out, especially as the only person
likely to imply any notions of "ownership" is you.
Richard.