You're creating an instance of myFunction and call toString on it before you set the prototype.
The reason you can create an instance of myFunction even before you declare it is because it was hoisted. toString is not hoisted however and it would show [Object object].
Solution is to create instances after you fully declare the object.
Note: A constructor function should start with a capital so it should be MyFunction instead of myFunction and maybe give it a name that actually means something like Person or Animal since nobody would have a clue to what a MyFunction is.
function myFunction(name) {
this.name = name;
//console.log is so much better than alert
console.log('this is:',this,'this.toString:'
, this.toString() );
};
myFunction.prototype.toString = function() {
return 'My name is ' + this.name;
};
var x = new myFunction('Hello World!');
More on prototype here: Prototypical inheritance - writing up