2D Vector class - written in JavaScript