However it doesn't necessarily cause a large slowdown, just makes your function polymorphic and the resulting optimized code larger and a bit slower.
To avoid this entirely I recommend using a JavaScript `class` when passing objects to a function that has to run at peak speed.
function vec3 (x, y, z) { return {x, y, z} }
I think they added this with ES2015.
However it doesn't necessarily cause a large slowdown, just makes your function polymorphic and the resulting optimized code larger and a bit slower.
To avoid this entirely I recommend using a JavaScript `class` when passing objects to a function that has to run at peak speed.