Instead of this: var test4 = Object. Create(Person); You should be doing: var test4 = Object. Create(Person.
Prototype); The way you had it, test4 had the Person function in its prototype chain, not the intended prototype object that has your toString method. Because of this, it was using a toString() method that is apparently anticipating being called against a Function object.
– Phat Wangrungarun Dec 19 at 6:32 @PhatWangrungarun: Yes, it overrides the Object.prototype. ToString method, which is the generic one. – RightSaidFred Dec 19 at 6:46 Get it now, thanks!
– Phat Wangrungarun Dec 19 at 6:53.
There is a difference between assigning to a prototype and assigning a new property to the prototype of an object. You declared a function Person as a constructor function, but then you are pretty much assigning something to its prototype by doing this: Person. Prototype = { toString: function() { return this.
FirstName + ' ' + this. LastName; } }; That means you assigning a new object key value pair toString-function to Person. Prototype, instead of actually adding a new property to it, in which you should have done like this: Person.prototype.
ToString = function() { return this. FirstName + ' ' + this. LastName; } What entails from this is that when you are actually creating a new object that inherits from Person object by calling Object.
Create, then what happens in its implementation is a new object will be freshly created, and then it will return that new object which will override the prototype property that javascript assumed you have created by doing that Person. Prototype assignment previously earlier in your code.
Var Person = function(firstName, lastName) { this. FirstName = firstName; this. LastName = lastName; }; var p1=new Person("Phat1","Wang1"); p1 is an Object var p2= Object.
Create(Person); p2. FirstName="Phat2"; p2. LastName="Wang2"; p2 is a function.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.