5 ms·
I don't understand something. Why calling new Person(..,..) returns toString()? The example calls: console.log( 'Full name is:', new Person('Michael', 'B
by martinrame 12y ago
I don't understand something.
Why calling new Person(..,..) returns toString()?
The example calls:
console.log(
'Full name is:',
new Person('Michael', 'Bluth2')
);
new Person should create an instance of Person, but why it calls toString()?.
- DecoPerson 12y ago"Every object has a toString() method that is automatically called when the object is to be represented as a text value or when an object is referred to in a manner in which a string is expected." https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- bpicolo 12y agoBecause you're console.logging it