js version of vector applying