Writing Math.max in JavaScript 0 ▲ Jake Worth 47 days ago · Tech · hide · Fediverse post For a recent talk I examined some native JavaScript functions in Node, and ended up reading the source code for Math.max: extern macro Float64Max(float64, float64): float64; transitioning javascript builtin MathMax( js-implicit context: NativeContext)(...arguments): Number { let result: float64 = MINUS_V8_INFINITY; const argCount = arguments.length; for (let i: intptr = 0; i < argCount; i++) { const doubleValue = TruncateTaggedToFloat64(arguments[i]); result = Float64Max(result, doubleValue); } return Convert<Number>(result); } To better understand this function, I decided to write my own version in JavaScript: Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town