Some more detail on constructor syntax? (SOLVED)


Hello, the tutorial for some object lesson says this: When you use the constructor, the syntax looks like this: Here is example of constructor syntax:

var myObj = new Object();

You can add keys to your object after you've created it in two ways:

myObj["name"] = "Charlie"; = "Charlie";

Both are correct, and the second is shorthand for the first.

I tried putting constructor shorthand into practice with this made up example(I always do my own practice drills with new spots):

var rock = newObject(); = "meteorite";
rock.age = 45,000,000;
rock.size = "very large";
rock.color = "orange";


When I attempt to run the code, I get object not defined. Can someone give a little more on Shorthand and constructor please?


You need a space between new and Object();


I see. Got it, thank you. Actually, while I did correct the error I asked about, it was only part of a bigger issue. It seems I was confusing creating an object with the constructor syntax. I somehow mixed up adding stuff to an object with the actual creation of one. And I was trying to use Constructor shorthand as an alternative method for creating an object from scratch. That was trippy...


I get the same error and I have a space between new and object

var me = new object();


Capitalize object.