Populating a Vector2 array in Javascript

For some reason, I can't seem to populate a vector2 array in Javascript.

function verts2uv(p:Vector3[]){
    var arr:Vector2[];
    for(var q:int=0;q<p.length;q++){
        arr[q]=Vector2(p[q].x,p[q].y);      
    }
    return arr;
}

I keep on getting this error: NullReferenceException: Object reference not set to an instance of an object

First, your code looks TERRIBLE. Use the space bar! Start your function names with a capital letter. And there is already an implicit conversion from Vector3 to Vector2.

The problem is that arr has not been initialized. You need to create and array of the appropriate size, before you do anything with it.

function Verts2UV (verts : Vector3[]) {
    var uv = new Vector2[verts.length];
    for (var i = 0; i < uv.Length; i++) uv _= verts*;*_
 _*return uv;*_
_*}*_
_*```*_