The variable d is not defined, which will cause a reference error; you’d probably want to pass it to the Project function as well. Anyhow the problem is not the argument you’re passing but the argument you’re not passing. ^^
Now you can indeed access any object properties using the [ ] notation – including numeric properties, over which you can then loop as in your second snippet, so no error there AFAICT. It just wouldn’t make too much sense to use a vertex instance as another vertex container, I think. (I used to suck really hard at this 3d geometry kind of stuff.) :-D Using a vanilla Array should be fine here anyway.
(BTW, by convention constructor functions start with capital letters, normal functions not – just the other way round!)
[quote=“Helioform, post:3, topic:244765, full:true”]
I know but im doing
var v = new vertex();
v[0]=vertex(0,0,0);
The first line is fine as the new keyword gives context to the this keyword within the vertex function. It’s the second where trouble occurs.
When execution passes from the second line to the vertex function , it has no context for the this keyword. When the this keyword is undefined, attempting to access things like this.x will result in the error that you are seeing.
If a function is supposed to be a constructor, always call it with the new keyword. It also helps to give the constructor function an a capital initial letter so that the naming convention acts as a reminder that it is a constructor.
When not running in strict mode, it is not vp.x that triggers the error. Instead, it is v.x that triggers the error for the value v is undefined. Why, because the vertex constructor was called without the new keyword.