Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
To make the most of vectors in JavaScript, we can encapsulate some of the functionality described earlier in a reusable object, thus making the vectors easier to use in applications. We can then easily attach any additional vector-related functionality to this object as needed.
The x and y components of the vector are actually called vx and vy in the vector object; this makes it more obvious in the later code examples that we are dealing with vector properties and not some other x and y values: