newpoint должен быть сначала массивом, вы не можете использовать:
var newpoint[0] = new Point(); //newpoint has to be declared on its own to be an array if you like to use [0] indexing;
Используйте
var newpoint = [];
newpoint[0] = new Point();
или
var newpoint = [new Point()]; //Cipi's suggestion for oneliner
Вам нужно () после типа. Новое ключевое слово вызывает метод конструктора, который может принимать параметры, поэтому вам нужно использовать ().
var newpoint[0] = new Point();
Также объявление класса не правильно
Объявление является вашим конструктором и должно возвращать его самостоятельно:
function Point()
{
this.x = null; //Or whatever default value you like
this.y = null;
/*
"This" makes the x and y variables members of the object instead of
local variables if the constructor function, without "this" they will
be forgotten as soon as the function ends. */
}
Вы можете добавлять методы в конструктор
function Point()
{
this.x = null; //Or whatever default value you like
this.y = null;
this.list = function ()
{
alert(this.x);
};
}
или с использованием прототипа
function Point()
{
this.x = null; //Or whatever default value you like
this.y = null;
}
Point.prototype.list = function ()
{
alert(this.x);
}