I've been learning Javascript's prototype inheritance, and I've got the following in a tag in the body of a html page:
function F() {}
//F.prototype = {a:"hello"};
var x = new F();
document.write(x.constructor);
This results in the following printout in the browser:
function F() { }
However , if I uncomment the second line, the following results:
function Object() { [native code] }
Nevertheless, x is still inheriting from the F's prototype, since when I change the last line to the following...
document.write(x.a);
...I get the following printout:
hello
I've tried this in Firefox and Safari, and the same thing happens in both.
Does anyone have any idea what on earth is going on here?