0

I was trying to get used to constructor functions and the protype chain, and I basically got inheritance and everything to work... I was wondering though, if there's something wrong with my way of creating objects of "new types": If I let firefox run this code:

function Point() {
    this.x = 0;
    this.y = 0;
}

var a = new Array();
var b = new Date();
var c = new Point();

console.log(typeof a,a);
console.log(typeof b,b);
console.log(typeof c,c);

...the console will output:

enter image description here

As you can see, even though all of them are basically objects, for a it says Array, for b Date, but for c only Object instead of Point

My question now is: Is this just a thing of the console, of build-in functions or can I get my point to be a Point?

Anton Ballmaier
  • 876
  • 9
  • 25
  • 1
    try `console.log(c.prototype.name)` to get the class name. own defined objects are allways displayed as Object – mtizziani Mar 19 '17 at 19:24

1 Answers1

1

Check out these questions:

You're basically on the right track, but the object type is not quite the same as the object class name, which is what you're looking for.

Community
  • 1
  • 1
Alpha
  • 7,586
  • 8
  • 59
  • 92