vector implementation on javascript