Real world examples of Ecmascript functions returning a Reference?
Solution 1:
Google Chrome's engine works very much in this way. However, you'll notice in the console you'll get an ReferenceError: Invalid left-hand side in assignment
when executing the following:
var myObj = new Object();
function myFunc() {
myObj.test = "blah";
return myObj;
}
myFunc() = new String("foobar");
This is an Early Error, however, and because the v8's ECMAScript implementation, this should work if it properly executes myFunc
before assuming the reference error.
So, in v8's current implementation? Yes and No. It is implemented by default (due to how the language is structured), however the capability is halted by a different issue. coolHostFn() = value
should not return an error, and should indeed be able to execute properly. However 3=4
should most certainly return a left-hand side assignment error.
Not exactly an answer to your question, but I hope it helps clarify why it doesn't work.
(Here's the Issue/Ticket in case anyone wants to chime in... http://code.google.com/p/v8/issues/detail?id=838 )