diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html index 60808dde44..590089e3c1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html @@ -50,12 +50,12 @@ Math.sign(); // NaN <h2 id="Compatibility" name="Compatibility">Polyfill</h2> -<pre class="brush: js language-js"><code class="language-js">function sign(x) { +<pre class="brush: js language-js">function sign(x) { x = +x ;// convert to a number if (x === 0 || isNaN(x)) return x; return x > 0 ? 1 : -1; -}</code></pre> +}</pre> <p> </p> |