JavaScript参考手册
Math
Math.acosh
Math.acosh()
返回一个数字的反双曲余弦值,即:
∀x≥1,Math.acosh(x)=arcosh(x)= the unique y≥0such thatcosh(y)=x\forall x \geq 1, \mathtt{\operatorname{Math.acosh}(x)} = \operatorname{arcosh}(x) = \text{ the unique } \; y \geq 0 \; \text{such that} \; \cosh(y) = x
语法
Math.acosh(x)
参数
x
一个数字。
返回值
返回指定参数的反双曲余弦值,如果指定的参数小于 1 则返回NaN
。
描述
因为acosh()
是Math对象的静态方法,所以你应该像这样使用它:Math.acosh()
, 而不是作为你创建的Math实例的属性(Math不是构造函数)。
示例
使用Math.acosh()
Math.acosh(-1); // NaN
Math.acosh(0); // NaN
Math.acosh(0.5); // NaN
Math.acosh(1); // 0
Math.acosh(2); // 1.3169578969248166
当参数小于1时, Math.acosh()
将返回NaN
。
Polyfill
当 x≥1时,都有 arcosh(x)=ln(x+x2-1) ,因此我们可以使用以下函数来模仿Math.acosh():
Math.acosh = Math.acosh || function(x) {
return Math.log(x + Math.sqrt(x * x - 1));
};
规范
Specification |
Status |
Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'Math.acosh' in that specification. |
Standard |
Initial definition. |
ECMAScript Latest Draft (ECMA-262)The definition of 'Math.acosh' in that specification. |
Draft |
|
浏览器兼容性
Feature |
Chrome |
Firefox |
Edge |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|---|
Basic Support |
38 |
25 |
(Yes) |
(No) |
25 |
7.1 |
Feature |
Android |
Chrome for Android |
Edge mobile |
Firefox for Android |
IE mobile |
Opera Android |
iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support |
(Yes) |
(Yes) |
(Yes) |
25 |
(No) |
(Yes) |
8 |
Math相关
JavaScript 是一种高级编程语言,通过解释执行,是一门动态类型,面向对象(基于原型)的解释型语言。它已经由ECMA(欧洲电脑制造商协会)通过 ECMAScript 实现语言的标准化。它被世界上的绝大多数网站所使用,也被世界主流浏览器( Chrome、IE、FireFox、Safari、Opera )支持。JavaScript 是一门基于原型、函数先行的语言,是一门多范式的语言,它支持面向对象编程,命令式编程,以及函数式编程。它提供语法来操控文本、数组、日期以及正则表达式等,不支持 I/O,比如网络