--- warning: This file is auto generated by `yarn web:inject`, do not edit by hand examples: - sqrt(16) - sqrt(2) returns: - '4' - '1.4142135623730951' dependencies: [] authors: original by: - Kevin van Zonneveld (https://kvz.io) notes: [] parityVerified: - Lua 5.4 isTypescript: true type: function layout: function title: Lua's math.sqrt in TypeScript description: >- Here's what our current TypeScript equivalent to Lua's math.sqrt looks like. function: sqrt category: math language: lua permalink: lua/math/sqrt/ alias: - /functions/lua/sqrt/ - /functions/math/sqrt/ - /lua/sqrt/ ---
{% codeblock lang:typescript %}export function sqrt(x: number): number { // discuss at: https://locutus.io/lua/sqrt/ // parity verified: Lua 5.4 // original by: Kevin van Zonneveld (https://kvz.io) // example 1: sqrt(16) // returns 1: 4 // example 2: sqrt(2) // returns 2: 1.4142135623730951 return Math.sqrt(x) } {% endcodeblock %}