Simulated Scalar operations in Javascript