file stringlengths 16 94 | text stringlengths 32 24.4k | vector list |
|---|---|---|
javascript/reference/global_objects/math/min/index.md | JavaScript - Global Objects - Math - min:
The `Math.min()` static method returns the smallest of the numbers given as input parameters, or `Infinity` if there are no parameters.
Example:
console.log(Math.min(2, 3, 1));
// Expected output: 1
console.log(Math.min(-2, -3, -1));
// Expected output: -3
const array = [2... | [
-0.970879316329956,
0.02153402753174305,
-1.454751968383789,
0.10240240395069122,
0.20904888212680817,
-0.891433596611023,
0.20285822451114655,
0.4068089425563812,
-0.26708218455314636,
0.3592664897441864,
-0.8816167712211609,
0.8386639952659607,
1.04778254032135,
-0.4350971579551697,
-0... |
javascript/reference/global_objects/math/min/index.md | JavaScript - Global Objects - Math - min - Syntax:
Example:
Math.min()
Math.min(value1)
Math.min(value1, value2)
Math.min(value1, value2, /* …, */ valueN) | [
-0.013128692284226418,
0.595544695854187,
-0.44848766922950745,
-0.06709649413824081,
-0.3216134309768677,
-1.2785364389419556,
-0.1884687840938568,
1.2166754007339478,
-0.4883660674095154,
-0.37928757071495056,
-0.8099111318588257,
0.5136758685112,
-0.2354286164045334,
-0.0689800530672073... |
javascript/reference/global_objects/math/min/index.md | JavaScript - Global Objects - Math - min - Syntax - Parameters:
- `value1`, …, `valueN`: Zero or more numbers among which the lowest value will be selected and returned. | [
-0.2521851062774658,
0.411878764629364,
-0.7920631766319275,
-0.06684718281030655,
-0.3248178958892822,
-0.8292093873023987,
0.41854506731033325,
0.8627150654792786,
-0.7551960945129395,
-0.14994007349014282,
-1.4113306999206543,
0.3560657501220703,
-0.19684384763240814,
0.1633754074573516... |
javascript/reference/global_objects/math/min/index.md | JavaScript - Global Objects - Math - min - Syntax - Return value:
The smallest of the given numbers. Returns `NaN` if any of the parameters is or is converted into `NaN`. Returns `Infinity` if no parameters are provided. | [
-1.1409330368041992,
0.6276705265045166,
-0.5508381128311157,
-0.20871493220329285,
-0.990791916847229,
-0.747245192527771,
1.0363763570785522,
-0.15631447732448578,
-0.46890249848365784,
0.6743842363357544,
-1.4273412227630615,
0.7495080232620239,
0.34917575120925903,
0.43309658765792847,... |
javascript/reference/global_objects/math/min/index.md | JavaScript - Global Objects - Math - min - Description:
Because `min()` is a static method of `Math`, you always use it as `Math.min()`, rather than as a method of a `Math` object you created (`Math` is not a constructor).
`Math.min.length` is 2, which weakly signals that it's designed to handle at least two paramete... | [
-0.9887793660163879,
-0.24994724988937378,
-1.0321465730667114,
0.19768419861793518,
0.12482298910617828,
-1.9259709119796753,
-0.2993786633014679,
0.885857343673706,
-0.7790162563323975,
0.3961983025074005,
-1.4901483058929443,
0.782653272151947,
0.4283588230609894,
-0.34810030460357666,
... |
javascript/reference/global_objects/math/min/index.md | JavaScript - Global Objects - Math - min - Examples - Using Math.min():
This finds the min of `x` and `y` and assigns it to `z`:
Example:
const x = 10;
const y = -20;
const z = Math.min(x, y); // -20 | [
-0.920172393321991,
0.36552703380584717,
-1.133911371231079,
0.4171680808067322,
0.0022887468803673983,
-0.42484408617019653,
0.5631561875343323,
-0.2709140181541443,
-0.14458884298801422,
0.14541226625442505,
-1.299352765083313,
0.8251139521598816,
-0.6801151633262634,
0.35475146770477295... |
javascript/reference/global_objects/math/min/index.md | JavaScript - Global Objects - Math - min - Examples - Clipping a value with Math.min():
`Math.min()` is often used to clip a value so that it is always less than or equal to a boundary. For instance, this
Example:
let x = f(foo);
if (x > boundary) {
x = boundary;
}
may be written as this
Example:
const x = Mat... | [
-1.6678051948547363,
-0.007941953837871552,
-1.0418384075164795,
-0.22413775324821472,
0.13117094337940216,
-0.9314805269241333,
0.4137200713157654,
0.9630940556526184,
-0.21670566499233246,
0.31380558013916016,
-0.9262673854827881,
0.5253223776817322,
0.08293147385120392,
-0.1579918712377... |
javascript/reference/global_objects/math/sign/index.md | JavaScript - Global Objects - Math - sign:
The `Math.sign()` static method returns 1 or -1, indicating the sign of the number passed as argument. If the input is 0 or -0, it will be returned as-is.
Example:
console.log(Math.sign(3));
// Expected output: 1
console.log(Math.sign(-3));
// Expected output: -1
console.... | [
-1.1061444282531738,
-0.30459555983543396,
-1.379559874534607,
-0.6278612613677979,
0.33444851636886597,
-1.6346197128295898,
0.16411878168582916,
1.6078948974609375,
-0.4462911784648895,
0.3795505166053772,
-0.1535876840353012,
0.4338224232196808,
1.0066112279891968,
-0.257543683052063,
... |
javascript/reference/global_objects/math/sign/index.md | JavaScript - Global Objects - Math - sign - Syntax:
Example:
Math.sign(x) | [
-0.48268768191337585,
0.21611562371253967,
-1.237699031829834,
-1.1017498970031738,
-0.7808576226234436,
-1.6122912168502808,
0.32920941710472107,
1.6304188966751099,
-0.17411580681800842,
-0.8129649758338928,
-0.009156066924333572,
0.6760001182556152,
0.2824982702732086,
-0.20701804757118... |
javascript/reference/global_objects/math/sign/index.md | JavaScript - Global Objects - Math - sign - Syntax - Parameters:
- `x`: A number. | [
-0.02008771523833275,
-0.17423851788043976,
-1.7444827556610107,
-1.3491032123565674,
-0.9140263795852661,
-1.5441842079162598,
0.3400849997997284,
1.1003257036209106,
0.2485380470752716,
-0.9560756683349609,
-0.9411131143569946,
0.18975505232810974,
0.08926516771316528,
0.1470064818859100... |
javascript/reference/global_objects/math/sign/index.md | JavaScript - Global Objects - Math - sign - Syntax - Return value:
A number representing the sign of `x`:
- If `x` is positive, returns `1`.
- If `x` is negative, returns `-1`.
- If `x` is positive zero, returns `0`.
- If `x` is negative zero, returns `-0`.
- Otherwise, returns `NaN`. | [
-1.2013673782348633,
0.1522413045167923,
-1.0313950777053833,
-0.334526389837265,
-0.4243300259113312,
-1.3753628730773926,
1.1600501537322998,
1.0603843927383423,
-0.48149189352989197,
0.2174748033285141,
-0.723257839679718,
0.31832730770111084,
-0.10689982026815414,
0.2544650137424469,
... |
javascript/reference/global_objects/math/sign/index.md | JavaScript - Global Objects - Math - sign - Description:
Because `sign()` is a static method of `Math`, you always use it as `Math.sign()`, rather than as a method of a `Math` object you created (`Math` is not a constructor). | [
-0.7941117286682129,
-0.07852990180253983,
-0.9361628890037537,
-0.4456298053264618,
-0.10516199469566345,
-2.3829097747802734,
-0.06055522337555885,
1.5641813278198242,
-0.15447430312633514,
0.16511468589305878,
-0.2403011918067932,
0.718488872051239,
0.9484871029853821,
-0.34600332379341... |
javascript/reference/global_objects/math/sign/index.md | JavaScript - Global Objects - Math - sign - Examples - Using Math.sign():
Example:
Math.sign(3); // 1
Math.sign(-3); // -1
Math.sign("-3"); // -1
Math.sign(0); // 0
Math.sign(-0); // -0
Math.sign(NaN); // NaN
Math.sign("foo"); // NaN
Math.sign(); // NaN | [
-0.6733630895614624,
-0.06175043433904648,
-0.9326373934745789,
-0.7722193598747253,
0.09542019665241241,
-1.2431824207305908,
0.7899124026298523,
1.2436867952346802,
-0.9939157962799072,
-0.05020977184176445,
-0.49537643790245056,
0.648634135723114,
0.4488910436630249,
-1.0593454837799072... |
javascript/reference/global_objects/math/sumprecise/index.md | JavaScript - Global Objects - Math - sumPrecise:
The `Math.sumPrecise()` static method takes an iterable of numbers and returns the sum of them. It is more precise than summing them up in a loop, because it avoids floating point precision loss in intermediate results.
Example:
console.log(Math.sumPrecise([1, 2]));
/... | [
-0.815601110458374,
-0.39666181802749634,
-1.5430153608322144,
-0.09507783502340317,
0.3011311888694763,
-1.1983094215393066,
0.2052324265241623,
0.653643786907196,
-0.3938555121421814,
0.9445800185203552,
-0.811066210269928,
1.0610721111297607,
0.4088846743106842,
-0.5282512903213501,
-... |
javascript/reference/global_objects/math/sumprecise/index.md | JavaScript - Global Objects - Math - sumPrecise - Syntax:
Example:
Math.sumPrecise(numbers) | [
-0.2753063142299652,
0.3265667259693146,
-0.7889045476913452,
-0.6532474160194397,
-0.6417221426963806,
-1.7640033960342407,
0.6397064328193665,
0.7250946164131165,
-0.24516162276268005,
-0.025669215247035027,
-0.7294188737869263,
0.8785001039505005,
0.14787167310714722,
-0.546050965785980... |
javascript/reference/global_objects/math/sumprecise/index.md | JavaScript - Global Objects - Math - sumPrecise - Syntax - Parameters:
- `numbers`: An iterable (such as an `Array`) of numbers. | [
0.2691267132759094,
0.0033768650609999895,
-0.8274269104003906,
-0.44198259711265564,
-0.2743665277957916,
-1.296920895576477,
0.49518999457359314,
0.6452502608299255,
-0.20547614991664886,
0.3289615213871002,
-1.4929991960525513,
0.7409712672233582,
-0.30847662687301636,
-0.00306407082825... |
javascript/reference/global_objects/math/sumprecise/index.md | JavaScript - Global Objects - Math - sumPrecise - Syntax - Return value:
A number that is the sum of the numbers in the `numbers` iterable. If the iterable is empty, the return value is `-0` (not `0`). | [
-0.41835349798202515,
0.4191184937953949,
-0.3087182641029358,
-0.24891157448291779,
-0.1987258791923523,
-1.0161501169204712,
0.8316454887390137,
0.9730933904647827,
-0.3467099964618683,
0.6156827211380005,
-0.8915718197822571,
1.2241560220718384,
-0.07357007265090942,
0.04790886119008064... |
javascript/reference/global_objects/math/sumprecise/index.md | JavaScript - Global Objects - Math - sumPrecise - Syntax - Exceptions:
- `TypeError`: If `numbers` is not an iterable, or if any of the numbers in the iterable is not of the number type. | [
-0.5722761750221252,
0.013418910093605518,
-0.1928424835205078,
-0.25769907236099243,
-0.15158890187740326,
-1.334731101989746,
-0.055994149297475815,
0.6188806891441345,
-0.5005826950073242,
-0.017499474808573723,
-0.6295310258865356,
-0.09088894724845886,
-0.08753453195095062,
-0.8214886... |
javascript/reference/global_objects/math/sumprecise/index.md | JavaScript - Global Objects - Math - sumPrecise - Description:
Because `sumPrecise()` is a static method of `Math`, you always use it as `Math.sumPrecise()`, rather than as a method of a `Math` object you created (`Math` is not a constructor).
The method is called `Math.sumPrecise()` because it is more precise than n... | [
-0.3878478407859802,
0.40604710578918457,
-1.4624531269073486,
0.00657250639051199,
0.7731525897979736,
-1.410509467124939,
0.22427648305892944,
0.6358089447021484,
-0.3852442800998688,
0.6959850788116455,
-0.9255790710449219,
1.1833438873291016,
0.40732261538505554,
-0.528668999671936,
... |
javascript/reference/global_objects/math/sumprecise/index.md | JavaScript - Global Objects - Math - sumPrecise - Examples - Using Math.sumPrecise():
Example:
console.log(Math.sumPrecise([1, 2, 3])); // 6
console.log(Math.sumPrecise([1e20, 0.1, -1e20])); // 0.1 | [
-0.36775287985801697,
0.3679320514202118,
-0.7828564047813416,
-0.23699040710926056,
-0.24979940056800842,
-1.7322282791137695,
0.05639117956161499,
0.2633051872253418,
-0.5815961956977844,
-0.5183488130569458,
-0.2590269446372986,
0.8627904057502747,
0.1829313188791275,
-0.873803734779357... |
javascript/reference/global_objects/math/trunc/index.md | JavaScript - Global Objects - Math - trunc:
The `Math.trunc()` static method returns the integer part of a number by removing any fractional digits.
Example:
console.log(Math.trunc(13.37));
// Expected output: 13
console.log(Math.trunc(42.84));
// Expected output: 42
console.log(Math.trunc(0.123));
// Expected out... | [
-1.3165624141693115,
0.21584239602088928,
-1.069815993309021,
-0.35154181718826294,
-0.07475246489048004,
-1.2763464450836182,
0.5407088994979858,
0.1339266300201416,
-0.3729760944843292,
0.881405234336853,
-1.1888982057571411,
0.32560816407203674,
-0.20628194510936737,
0.1846315562725067,... |
javascript/reference/global_objects/math/trunc/index.md | JavaScript - Global Objects - Math - trunc - Syntax:
Example:
Math.trunc(x) | [
-0.7902320623397827,
0.924694299697876,
-1.149924635887146,
-1.1833137273788452,
-1.2089592218399048,
-1.7275681495666504,
0.596226692199707,
0.6503822207450867,
-0.020368387922644615,
-0.21533450484275818,
-0.6413039565086365,
0.048675667494535446,
-0.220123291015625,
0.040288180112838745... |
javascript/reference/global_objects/math/trunc/index.md | JavaScript - Global Objects - Math - trunc - Syntax - Parameters:
- `x`: A number. | [
-0.6939539313316345,
0.1864462047815323,
-1.5789567232131958,
-1.2898492813110352,
-1.0958101749420166,
-1.5806583166122437,
0.49420514702796936,
0.41780245304107666,
0.21399614214897156,
-0.3546575903892517,
-1.4240937232971191,
-0.33290573954582214,
-0.2931029200553894,
0.380294561386108... |
javascript/reference/global_objects/math/trunc/index.md | JavaScript - Global Objects - Math - trunc - Syntax - Return value:
The integer part of `x`. | [
-1.012281060218811,
0.6989924907684326,
-1.012596845626831,
-0.7788408398628235,
-0.8302401900291443,
-1.184720754623413,
0.9515964388847351,
0.4022691249847412,
0.09276115894317627,
0.42582499980926514,
-0.8129790425300598,
0.1393132209777832,
-0.2873477041721344,
0.8033722043037415,
0.... |
javascript/reference/global_objects/math/trunc/index.md | JavaScript - Global Objects - Math - trunc - Description:
The way `Math.trunc()` works is more straightforward than the other three `Math` methods: `Math.floor()`, `Math.ceil()` and `Math.round()`; it truncates (cuts off) the dot and the digits to the right of it, no matter whether the argument is a positive or negati... | [
-1.3195044994354248,
0.7314184904098511,
-0.700629711151123,
-0.2932308316230774,
-0.11918079853057861,
-1.6634721755981445,
0.38579612970352173,
0.3501165509223938,
-0.10910732299089432,
0.9958286881446838,
-1.5322870016098022,
0.006219304166734219,
0.19205710291862488,
-0.213410913944244... |
javascript/reference/global_objects/math/trunc/index.md | JavaScript - Global Objects - Math - trunc - Examples - Using Math.trunc():
Example:
Math.trunc(-Infinity); // -Infinity
Math.trunc("-1.123"); // -1
Math.trunc(-0.123); // -0
Math.trunc(-0); // -0
Math.trunc(0); // 0
Math.trunc(0.123); // 0
Math.trunc(13.37); // 13
Math.trunc(42.84); // 42
Math.trunc(Infinity); // In... | [
-1.6940362453460693,
0.7905007004737854,
-0.5582073330879211,
-0.4711681008338928,
-0.67482590675354,
-1.641789436340332,
0.31369346380233765,
-0.13365770876407623,
-0.2894243001937866,
-0.3006610870361328,
-1.1345092058181763,
-0.10877906531095505,
0.2925918698310852,
0.024076277390122414... |
javascript/reference/global_objects/math/trunc/index.md | JavaScript - Global Objects - Math - trunc - Examples - Using bitwise no-ops to truncate numbers:
Warning: This is not a polyfill for `Math.trunc()` because of non-negligible edge cases.
Bitwise operations convert their operands to 32-bit integers, which people have historically taken advantage of to truncate float-p... | [
-0.9326549172401428,
0.6600836515426636,
-0.8000454306602478,
0.35822024941444397,
0.15315477550029755,
-1.307867407798767,
0.7014131546020508,
0.46878424286842346,
0.10133618861436844,
1.229318618774414,
-1.2843235731124878,
-0.32259616255760193,
0.30953875184059143,
-0.30126285552978516,... |
javascript/reference/global_objects/math/acosh/index.md | JavaScript - Global Objects - Math - acosh:
The `Math.acosh()` static method returns the inverse hyperbolic cosine of a number. That is,
Example:
console.log(Math.acosh(0.999999999999));
// Expected output: NaN
console.log(Math.acosh(1));
// Expected output: 0
console.log(Math.acosh(2));
// Expected output: 1.3169... | [
-0.26901230216026306,
-0.5620699524879456,
-1.10378897190094,
0.0453144796192646,
-0.18784792721271515,
-1.027573823928833,
0.28031960129737854,
0.40997228026390076,
-0.6276609897613525,
1.30365788936615,
-1.0590169429779053,
0.6046217083930969,
0.9451571702957153,
0.10714617371559143,
0... |
javascript/reference/global_objects/math/acosh/index.md | JavaScript - Global Objects - Math - acosh - Syntax:
Example:
Math.acosh(x) | [
0.6851347088813782,
0.2099897563457489,
-1.2684893608093262,
-1.1329386234283447,
-1.1653330326080322,
-1.851069688796997,
0.7882363796234131,
0.8011980056762695,
0.25635334849357605,
-0.32278695702552795,
-0.5375959277153015,
0.6784244179725647,
0.011042539961636066,
0.3406371474266052,
... |
javascript/reference/global_objects/math/acosh/index.md | JavaScript - Global Objects - Math - acosh - Syntax - Parameters:
- `x`: A number greater than or equal to 1. | [
0.5592615604400635,
-0.6874091029167175,
-1.079737901687622,
-1.116031289100647,
-0.8484482169151306,
-1.7446212768554688,
0.6839745044708252,
0.5027549862861633,
0.5245069265365601,
-0.5982800126075745,
-1.2855613231658936,
-0.0024375682696700096,
-0.5629405379295349,
0.5071384906768799,
... |
javascript/reference/global_objects/math/acosh/index.md | JavaScript - Global Objects - Math - acosh - Syntax - Return value:
The inverse hyperbolic cosine of `x`. If `x` is less than 1, returns `NaN`. | [
-0.6636556386947632,
-0.24615442752838135,
-0.4103150963783264,
0.045747026801109314,
-0.681988000869751,
-0.8446058630943298,
0.8674535155296326,
0.6648780107498169,
-0.8241445422172546,
0.8528626561164856,
-1.8124572038650513,
0.2654905617237091,
0.23800620436668396,
0.5594804883003235,
... |
javascript/reference/global_objects/math/acosh/index.md | JavaScript - Global Objects - Math - acosh - Description:
Because `acosh()` is a static method of `Math`, you always use it as `Math.acosh()`, rather than as a method of a `Math` object you created (`Math` is no constructor). | [
0.13059101998806,
-0.48038598895072937,
-0.9818660616874695,
-0.2638217508792877,
-0.18152591586112976,
-2.5196454524993896,
0.3828989565372467,
0.9455176591873169,
0.34600159525871277,
0.713654100894928,
-0.6825624108314514,
0.4044930040836334,
1.0289665460586548,
-0.01681060716509819,
... |
javascript/reference/global_objects/math/acosh/index.md | JavaScript - Global Objects - Math - acosh - Examples - Using Math.acosh():
Example:
Math.acosh(0); // NaN
Math.acosh(1); // 0
Math.acosh(2); // 1.3169578969248166
Math.acosh(Infinity); // Infinity | [
-0.45955121517181396,
0.3464541733264923,
-0.3009909689426422,
-0.6161555051803589,
-0.6589506268501282,
-1.2052180767059326,
0.7910401225090027,
-0.4069536626338959,
-0.4863598644733429,
0.09887969493865967,
-0.8003283739089966,
0.22568580508232117,
0.5915043354034424,
-0.2117331475019455... |
javascript/reference/global_objects/math/exp/index.md | JavaScript - Global Objects - Math - exp:
The `Math.exp()` static method returns e raised to the power of a number. That is
Example:
console.log(Math.exp(0));
// Expected output: 1
console.log(Math.exp(1));
// Expected output: 2.718281828459 (approximately)
console.log(Math.exp(-1));
// Expected output: 0.36787944... | [
-1.4265122413635254,
-0.25960826873779297,
-0.7840108871459961,
-0.2467576265335083,
-0.015597104094922543,
-1.5781141519546509,
0.40097999572753906,
0.9844921827316284,
-0.16485866904258728,
0.14510765671730042,
0.05780820548534393,
1.1999807357788086,
-0.19613443315029144,
-0.34678354859... |
javascript/reference/global_objects/math/exp/index.md | JavaScript - Global Objects - Math - exp - Syntax:
Example:
Math.exp(x) | [
-0.6635847091674805,
0.029070556163787842,
-0.9519408345222473,
-0.6485662460327148,
-1.148667573928833,
-1.461161732673645,
0.4842909872531891,
1.2680349349975586,
0.5003948211669922,
-0.6070247888565063,
-0.16061893105506897,
1.0525435209274292,
-0.2980012893676758,
-0.11310069262981415,... |
javascript/reference/global_objects/math/exp/index.md | JavaScript - Global Objects - Math - exp - Syntax - Parameters:
- `x`: A number. | [
-0.3097909390926361,
-0.459267258644104,
-1.4852851629257202,
-0.977752149105072,
-0.9388782382011414,
-1.2847436666488647,
0.569277822971344,
0.9221739172935486,
0.6304168105125427,
-0.7324439287185669,
-0.785792887210846,
0.543444812297821,
-0.30274781584739685,
0.20400390028953552,
0.... |
javascript/reference/global_objects/math/exp/index.md | JavaScript - Global Objects - Math - exp - Syntax - Return value:
A nonnegative number representing ex, where e is the base of the natural logarithm. | [
-0.4778914153575897,
-0.3679967522621155,
-1.0888042449951172,
-0.3803037106990814,
-0.9949591755867004,
-0.8904462456703186,
0.33533963561058044,
0.5447108745574951,
0.03982803225517273,
0.09259974211454391,
-0.5849600434303284,
1.1319432258605957,
-0.5627389550209045,
0.8068698644638062,... |
javascript/reference/global_objects/math/exp/index.md | JavaScript - Global Objects - Math - exp - Description:
Because `exp()` is a static method of `Math`, you always use it as `Math.exp()`, rather than as a method of a `Math` object you created (`Math` is not a constructor).
Beware that `e` to the power of a number very close to 0 will be very close to 1 and suffer fro... | [
-1.3999361991882324,
-0.018999407067894936,
-0.5172858834266663,
0.24594594538211823,
0.08859702199697495,
-2.4999520778656006,
0.6898584961891174,
0.9172889590263367,
0.08911964297294617,
0.6264611482620239,
-0.7580749988555908,
1.1477235555648804,
0.03216628357768059,
-0.5388814210891724... |
javascript/reference/global_objects/math/exp/index.md | JavaScript - Global Objects - Math - exp - Examples - Using Math.exp():
Example:
Math.exp(-Infinity); // 0
Math.exp(-1); // 0.36787944117144233
Math.exp(0); // 1
Math.exp(1); // 2.718281828459045
Math.exp(Infinity); // Infinity | [
-1.9306174516677856,
0.28412213921546936,
-0.25545063614845276,
-0.0737423375248909,
-0.5044563412666321,
-1.056251049041748,
0.4637812376022339,
-0.07781951874494553,
0.2315954566001892,
-0.5382908582687378,
-0.4129987061023712,
0.4263327419757843,
0.20941759645938873,
-0.7169976234436035... |
javascript/reference/global_objects/math/ln2/index.md | JavaScript - Global Objects - Math - LN2:
The `Math.LN2` static data property represents the natural logarithm of 2, approximately 0.693:
Example:
function getNatLog2() {
return Math.LN2;
}
console.log(getNatLog2());
// Expected output: 0.6931471805599453 | [
-1.7081791162490845,
0.22397607564926147,
-0.6117600798606873,
0.027867233380675316,
-0.8519907593727112,
-1.048720359802246,
-1.2809900045394897,
0.1033911481499672,
-0.37488946318626404,
0.006672814954072237,
-0.5592028498649597,
0.5479699969291687,
-0.3053548038005829,
-0.08818741887807... |
javascript/reference/global_objects/math/ln2/index.md | JavaScript - Global Objects - Math - LN2 - Description:
Because `LN2` is a static property of `Math`, you always use it as `Math.LN2`, rather than as a property of a `Math` object you created (`Math` is not a constructor). | [
-1.67709481716156,
0.1783825308084488,
-0.3340092897415161,
0.14215552806854248,
-0.40503326058387756,
-1.9087151288986206,
-0.40974706411361694,
1.2532172203063965,
-0.12166737765073776,
-0.03638841584324837,
-0.8191161751747131,
0.7551851272583008,
-0.12925942242145538,
-0.10398314148187... |
javascript/reference/global_objects/math/ln2/index.md | JavaScript - Global Objects - Math - LN2 - Examples - Using Math.LN2:
The following function returns the natural log of 2:
Example:
function getNatLog2() {
return Math.LN2;
}
getNatLog2(); // 0.6931471805599453 | [
-1.4154783487319946,
0.9105005264282227,
-0.7006616592407227,
-0.2669772505760193,
-1.3578611612319946,
-0.7288132309913635,
-0.39516547322273254,
0.05000326409935951,
-1.1367934942245483,
-0.408958375453949,
-0.41664955019950867,
0.691308319568634,
-0.5927601456642151,
0.3279670774936676,... |
javascript/reference/global_objects/math/expm1/index.md | JavaScript - Global Objects - Math - expm1:
The `Math.expm1()` static method returns e raised to the power of a number, subtracted by 1. That is
Example:
console.log(Math.expm1(0));
// Expected output: 0
console.log(Math.expm1(1));
// Expected output: 1.718281828459045
console.log(Math.expm1(-1));
// Expected outp... | [
-1.5799036026000977,
-0.16624604165554047,
-0.8740289211273193,
-0.6225555539131165,
0.13023284077644348,
-1.9306740760803223,
0.1263497918844223,
0.7825727462768555,
0.15096616744995117,
0.20853637158870697,
-0.7243694067001343,
0.7392606139183044,
-0.5108685493469238,
-0.4743150472640991... |
javascript/reference/global_objects/math/expm1/index.md | JavaScript - Global Objects - Math - expm1 - Syntax:
Example:
Math.expm1(x) | [
-0.6173768043518066,
0.40930086374282837,
-0.9628067016601562,
-1.0628025531768799,
-1.0968979597091675,
-1.8323078155517578,
0.07150834053754807,
1.13640558719635,
0.7873479127883911,
-0.7144009470939636,
-0.6192594170570374,
0.7386924028396606,
-0.40521398186683655,
-0.4408337473869324,
... |
javascript/reference/global_objects/math/expm1/index.md | JavaScript - Global Objects - Math - expm1 - Syntax - Parameters:
- `x`: A number. | [
-0.36204051971435547,
-0.6065452694892883,
-1.5139079093933105,
-1.2354507446289062,
-0.9747303128242493,
-1.7368749380111694,
0.26737335324287415,
0.7881454229354858,
0.8268372416496277,
-0.8747839331626892,
-1.134229302406311,
0.5656169056892395,
-0.3894316554069519,
0.06275278329849243,... |
javascript/reference/global_objects/math/expm1/index.md | JavaScript - Global Objects - Math - expm1 - Syntax - Return value:
A number representing ex - 1, where e is the base of the natural logarithm. | [
-0.47521430253982544,
-0.2055409550666809,
-1.3811326026916504,
-0.6356130242347717,
-0.7459033131599426,
-1.5248804092407227,
-0.15870194137096405,
0.7600402235984802,
0.3415411412715912,
-0.19288210570812225,
-0.9347225427627563,
1.396785020828247,
-0.8224760890007019,
0.8941333293914795... |
javascript/reference/global_objects/math/expm1/index.md | JavaScript - Global Objects - Math - expm1 - Description:
For very small values of x, adding 1 can reduce or eliminate precision. The double floats used in JS give you about 15 digits of precision. 1 + 1e-15 1.000000000000001, but 1 + 1e-16 = 1.000000000000000 and therefore exactly 1.0 in that arithmetic, because dig... | [
-1.3694206476211548,
-0.5297991037368774,
-1.4426578283309937,
0.15990905463695526,
0.11283493787050247,
-1.4860179424285889,
0.7735724449157715,
0.273237019777298,
-0.14599493145942688,
0.24461260437965393,
-1.0800118446350098,
1.3414894342422485,
-1.3798930644989014,
0.06463252753019333,... |
javascript/reference/global_objects/math/expm1/index.md | JavaScript - Global Objects - Math - expm1 - Examples - Using Math.expm1():
Example:
Math.expm1(-Infinity); // -1
Math.expm1(-1); // -0.6321205588285577
Math.expm1(-0); // -0
Math.expm1(0); // 0
Math.expm1(1); // 1.718281828459045
Math.expm1(Infinity); // Infinity | [
-1.8280799388885498,
0.14187456667423248,
-0.2537524700164795,
-0.29553771018981934,
-0.3738560676574707,
-1.8910194635391235,
0.013310126028954983,
-0.19250555336475372,
0.45576244592666626,
-0.6354662179946899,
-0.9468161463737488,
0.4697362184524536,
-0.03426197171211243,
-0.61509442329... |
javascript/reference/global_objects/math/log10/index.md | JavaScript - Global Objects - Math - log10:
The `Math.log10()` static method returns the base 10 logarithm of a number. That is
Example:
console.log(Math.log10(100000));
// Expected output: 5
console.log(Math.log10(2));
// Expected output: 0.3010299956639812
console.log(Math.log10(1));
// Expected output: 0
conso... | [
-0.15100930631160736,
-0.17573761940002441,
-1.8158515691757202,
-0.061619047075510025,
0.06314031779766083,
-1.821179986000061,
-0.2521646022796631,
0.5381554961204529,
-0.1624050885438919,
0.09147030860185623,
-0.627819836139679,
0.670932948589325,
0.17298683524131775,
0.1697439402341842... |
javascript/reference/global_objects/math/log10/index.md | JavaScript - Global Objects - Math - log10 - Syntax:
Example:
Math.log10(x) | [
0.29367971420288086,
0.47099563479423523,
-1.487112045288086,
-0.8047106266021729,
-0.9434311389923096,
-1.888883113861084,
0.227249875664711,
0.8618806004524231,
-0.23029515147209167,
-0.9544999003410339,
-0.32128629088401794,
0.5403178930282593,
-0.14998574554920197,
0.19758792221546173,... |
javascript/reference/global_objects/math/log10/index.md | JavaScript - Global Objects - Math - log10 - Syntax - Parameters:
- `x`: A number greater than or equal to 0. | [
-0.14238806068897247,
-0.3996124267578125,
-1.248659610748291,
-0.6493005752563477,
-0.8599703311920166,
-1.5487029552459717,
0.37091225385665894,
0.8235164284706116,
0.2990964949131012,
-0.9903102517127991,
-1.1141701936721802,
0.08464392274618149,
-0.4215240180492401,
0.14071689546108246... |
javascript/reference/global_objects/math/log10/index.md | JavaScript - Global Objects - Math - log10 - Syntax - Return value:
The base 10 logarithm of `x`. If `x < 0`, returns `NaN`. | [
0.045037444680929184,
0.2950677275657654,
-1.2953394651412964,
-0.599741518497467,
-0.5569669008255005,
-1.043839454650879,
0.7598097324371338,
0.4007922112941742,
-0.6769527792930603,
-0.13534106314182281,
-0.9445943236351013,
0.7692688703536987,
-0.5824988484382629,
0.6015734076499939,
... |
javascript/reference/global_objects/math/log10/index.md | JavaScript - Global Objects - Math - log10 - Description:
Because `log10()` is a static method of `Math`, you always use it as `Math.log10()`, rather than as a method of a `Math` object you created (`Math` is not a constructor).
This function is the equivalent of `Math.log(x) / Math.log(10)`. For `log10(e)`, use the ... | [
-0.20149248838424683,
0.09066584706306458,
-1.2981019020080566,
-0.1763395518064499,
-0.0851651281118393,
-2.2899062633514404,
-0.21204014122486115,
1.272524356842041,
-0.45329034328460693,
0.3575729429721832,
-0.7541893124580383,
0.5352644324302673,
0.26746341586112976,
-0.133928433060646... |
javascript/reference/global_objects/math/log10/index.md | JavaScript - Global Objects - Math - log10 - Examples - Using Math.log10():
Example:
Math.log10(-2); // NaN
Math.log10(-0); // -Infinity
Math.log10(0); // -Infinity
Math.log10(1); // 0
Math.log10(2); // 0.3010299956639812
Math.log10(100000); // 5
Math.log10(Infinity); // Infinity | [
-0.6201373338699341,
0.2160322219133377,
-0.7806195616722107,
-0.2617540657520294,
-0.3415537178516388,
-1.6052016019821167,
0.3405260741710663,
0.003827687120065093,
-0.48318251967430115,
-0.6307404041290283,
-0.7596627473831177,
0.2067311704158783,
0.1303292214870453,
-0.3188146352767944... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random:
The `Math.random()` static method returns a floating-point, pseudo-random number that's greater than or equal to 0 and less than 1, with approximately uniform distribution over that range — which you can then scale to your desired range. The implementation selects the initi... | [
-1.1547797918319702,
0.030438940972089767,
-1.2968745231628418,
-0.2408885657787323,
0.17972896993160248,
-0.4889673888683319,
0.23901624977588654,
1.1336984634399414,
-0.8243920803070068,
0.7166974544525146,
-1.3842849731445312,
1.4284526109695435,
-0.32960647344589233,
-0.369162708520889... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Syntax:
Example:
Math.random() | [
-0.3736599087715149,
0.3037593364715576,
-0.165018692612648,
-0.7338966131210327,
-0.7365096211433411,
-1.2909133434295654,
0.39080971479415894,
1.1481746435165405,
-0.5220565795898438,
-0.7365715503692627,
-1.0637435913085938,
0.8339322209358215,
-0.24447736144065857,
-0.09289760142564774... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Syntax - Parameters:
None. | [
-0.41280579566955566,
0.4544101655483246,
-0.6907691359519958,
-1.133101463317871,
-0.5612848997116089,
-0.8532077670097351,
0.7853453755378723,
1.2064542770385742,
-0.24976253509521484,
-0.6550648808479309,
-1.4260355234146118,
0.11371287703514099,
-0.00105375109706074,
0.1777772158384323... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Syntax - Return value:
A floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive). | [
-0.9162293076515198,
-0.18046893179416656,
-0.4269844889640808,
-0.6212078928947449,
-0.23080848157405853,
-0.7759978771209717,
0.12198327481746674,
1.0403053760528564,
-0.1863621473312378,
-0.09806588292121887,
-1.344240427017212,
1.653775930404663,
-0.32704758644104004,
0.133464932441711... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Examples:
Note that as numbers in JavaScript are IEEE 754 floating point numbers with round-to-nearest-even behavior, the ranges claimed for the functions below (excluding the one for `Math.random()` itself) aren't exact. Usually, the claimed upper bound is not attainable,... | [
-1.518489122390747,
0.8166519999504089,
-0.5505595803260803,
-0.40087375044822693,
-0.18487036228179932,
-1.2611242532730103,
0.03961329162120819,
0.624565601348877,
-1.659147024154663,
0.0404479019343853,
-0.9297528266906738,
1.3482526540756226,
-0.9588147401809692,
0.08717264235019684,
... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Examples - Getting a random number between 0 (inclusive) and 1 (exclusive):
Example:
function getRandom() {
return Math.random();
} | [
-1.266512393951416,
0.31287771463394165,
-0.5949382185935974,
-0.6834659576416016,
-0.5264109373092651,
-1.1709994077682495,
0.05540354177355766,
0.29718926548957825,
-0.6054374575614929,
-0.36338937282562256,
-0.9814712405204773,
0.8296091556549072,
-0.5287972688674927,
-0.382079064846038... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Examples - Getting a random number between two values:
This example returns a random number between the specified values. The returned value is no lower than (and may possibly equal) `min`, and is less than (and not equal) `max`.
Example:
function getRandomArbitrary(min,... | [
-0.9591774344444275,
-0.26683512330055237,
-0.7725818753242493,
-0.2517004907131195,
-0.8624518513679504,
-0.2711431384086609,
0.5102359056472778,
0.6822147369384766,
-0.4178403317928314,
-0.4663994312286377,
-1.2488155364990234,
0.8129566311836243,
-0.7689532041549683,
0.19391454756259918... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Examples - Getting a random integer between two values:
This example returns a random integer between the specified values. The value is no lower than `min` (or the next integer greater than `min` if `min` isn't an integer), and is less than (but not equal to) `max`.
Exam... | [
-0.9039016962051392,
0.4958638846874237,
-0.3151415288448334,
0.8069398403167725,
0.355388879776001,
-0.39826416969299316,
0.42336201667785645,
0.44794121384620667,
-0.6212237477302551,
0.6206663250923157,
-1.0941720008850098,
0.3341532051563263,
-0.8393310904502869,
0.05893837660551071,
... |
javascript/reference/global_objects/math/random/index.md | JavaScript - Global Objects - Math - random - Examples - Getting a random integer between two values, inclusive:
While the `getRandomInt()` function above is inclusive at the minimum, it's exclusive at the maximum. What if you need the results to be inclusive at both the minimum and the maximum? The `getRandomIntInclu... | [
-1.1005685329437256,
0.3760504424571991,
-0.4413668215274811,
0.7906370162963867,
0.3370879292488098,
-0.07375828176736832,
0.37738654017448425,
0.11610404402017593,
-0.5106242895126343,
-0.15181316435337067,
-0.44188252091407776,
0.6662077307701111,
-0.7033172249794006,
-0.056836389005184... |
javascript/reference/global_objects/math/atan/index.md | JavaScript - Global Objects - Math - atan:
The `Math.atan()` static method returns the inverse tangent (in radians) of a number, that is
Example:
// Calculates angle of a right-angle triangle in radians
function calcAngle(opposite, adjacent) {
return Math.atan(opposite / adjacent);
}
console.log(calcAngle(8, 10))... | [
-0.2328747808933258,
0.21967831254005432,
-1.6828341484069824,
-0.3478219509124756,
-0.21379856765270233,
-0.710109531879425,
0.5489650964736938,
0.6718944311141968,
-0.7427046298980713,
0.6499656438827515,
-0.7294428944587708,
0.93045574426651,
-0.16049253940582275,
0.2515121400356293,
... |
javascript/reference/global_objects/math/atan/index.md | JavaScript - Global Objects - Math - atan - Syntax:
Example:
Math.atan(x) | [
0.5139408111572266,
0.3894073963165283,
-1.2983934879302979,
-0.5434616208076477,
-1.3200892210006714,
-1.1488769054412842,
0.6359272599220276,
0.8987502455711365,
-0.4730881154537201,
-0.6964616775512695,
-0.5009254813194275,
0.39423900842666626,
-0.9774962663650513,
0.16138856112957,
0... |
javascript/reference/global_objects/math/atan/index.md | JavaScript - Global Objects - Math - atan - Syntax - Parameters:
- `x`: A number. | [
0.44431737065315247,
-0.47431549429893494,
-1.7457860708236694,
-1.0853509902954102,
-1.0938466787338257,
-1.2314910888671875,
0.6571424603462219,
0.7410525679588318,
0.047373078763484955,
-0.5121915936470032,
-1.0860636234283447,
0.06024143472313881,
-0.7270938754081726,
0.333101272583007... |
javascript/reference/global_objects/math/atan/index.md | JavaScript - Global Objects - Math - atan - Syntax - Return value:
The inverse tangent (angle in radians between -π2-\frac{\pi}{2} and π2\frac{\pi}{2}, inclusive) of `x`. If `x` is `Infinity`, it returns π2\frac{\pi}{2}. If `x` is `-Infinity`, it returns -π2-\frac{\pi}{2}. | [
-2.054093599319458,
0.4347609281539917,
-0.4996436536312103,
0.2312587946653366,
-0.7271435260772705,
-0.4783267378807068,
0.8989959359169006,
0.48241665959358215,
-0.12941300868988037,
0.4728449583053589,
-0.6117556691169739,
0.9978989362716675,
0.10450047999620438,
0.528809130191803,
0... |
javascript/reference/global_objects/math/atan/index.md | JavaScript - Global Objects - Math - atan - Description:
Because `atan()` is a static method of `Math`, you always use it as `Math.atan()`, rather than as a method of a `Math` object you created (`Math` is not a constructor). | [
0.04026228189468384,
-0.3333260118961334,
-1.0381850004196167,
0.114596888422966,
-0.5969018936157227,
-2.109051465988159,
0.1570752114057541,
1.0401043891906738,
-0.3346351683139801,
0.24462467432022095,
-0.7364824414253235,
0.5281981825828552,
-0.13136564195156097,
-0.02950935624539852,
... |
javascript/reference/global_objects/math/atan/index.md | JavaScript - Global Objects - Math - atan - Examples - Using Math.atan():
Example:
Math.atan(-Infinity); // -1.5707963267948966 (-π/2)
Math.atan(-0); // -0
Math.atan(0); // 0
Math.atan(1); // 0.7853981633974483 (π/4)
Math.atan(Infinity); // 1.5707963267948966 (π/2)
// The angle that the line (0,0) -- (x,y) forms w... | [
-0.4310718774795532,
0.5054557919502258,
-1.477140188217163,
-0.048894576728343964,
0.005296746734529734,
-0.4640876054763794,
-0.21076427400112152,
0.5868387222290039,
-0.22745580971240997,
0.24106794595718384,
-0.4976625144481659,
0.14210788905620575,
0.06666278839111328,
-0.055940944701... |
javascript/reference/global_objects/math/sqrt1_2/index.md | JavaScript - Global Objects - Math - SQRT1_2:
The `Math.SQRT1_2` static data property represents the square root of 1/2, which is approximately 0.707.
Example:
function getRoot1Over2() {
return Math.SQRT1_2;
}
console.log(getRoot1Over2());
// Expected output: 0.7071067811865476 | [
-1.9872130155563354,
0.5248708724975586,
-1.1146544218063354,
-0.1597774773836136,
-0.36455807089805603,
-1.8194471597671509,
-0.523563802242279,
0.3224030137062073,
0.110434889793396,
-0.4406488537788391,
-0.45552295446395874,
0.9113284945487976,
-0.25583502650260925,
-0.46431764960289,
... |
javascript/reference/global_objects/math/sqrt1_2/index.md | JavaScript - Global Objects - Math - SQRT1_2 - Description:
`Math.SQRT1_2` is a constant and a more performant equivalent to `Math.sqrt(0.5)`.
Because `SQRT1_2` is a static property of `Math`, you always use it as `Math.SQRT1_2`, rather than as a property of a `Math` object you created (`Math` is not a constructor). | [
-1.490971326828003,
0.32188665866851807,
-0.6507174372673035,
-0.08655790239572525,
0.01953423023223877,
-1.9549334049224854,
-0.3603886663913727,
0.9209005236625671,
0.6729651689529419,
0.3154882788658142,
-1.278141736984253,
0.37722498178482056,
0.17334581911563873,
-0.32261404395103455,... |
javascript/reference/global_objects/math/sqrt1_2/index.md | JavaScript - Global Objects - Math - SQRT1_2 - Examples - Using Math.SQRT1_2:
The following function calculates the side length of a square given its diagonal length:
Example:
function getSquareSideLength(diagonalLength) {
return diagonalLength * Math.SQRT1_2;
} | [
-1.6678541898727417,
1.2011984586715698,
-1.5322550535202026,
-1.1413737535476685,
-0.8284953832626343,
0.011973398737609386,
0.30891314148902893,
0.000580105057451874,
-0.10580108314752579,
-0.2833282947540283,
-1.0156193971633911,
0.7690548896789551,
-0.6602542400360107,
0.05139975622296... |
javascript/reference/global_objects/math/floor/index.md | JavaScript - Global Objects - Math - floor:
The `Math.floor()` static method always rounds down and returns the largest integer less than or equal to a given number.
Example:
console.log(Math.floor(5.95));
// Expected output: 5
console.log(Math.floor(5.05));
// Expected output: 5
console.log(Math.floor(5));
// Exp... | [
-1.2694368362426758,
0.11503302305936813,
-1.529499888420105,
0.29035910964012146,
0.1355951577425003,
-0.7547881007194519,
-0.2485620230436325,
0.572985827922821,
-0.7399283647537231,
0.42400088906288147,
-0.2731427550315857,
1.5391086339950562,
-0.39626193046569824,
0.4022868275642395,
... |
javascript/reference/global_objects/math/floor/index.md | JavaScript - Global Objects - Math - floor - Syntax:
Example:
Math.floor(x) | [
-0.44334542751312256,
0.6469234824180603,
-1.4246071577072144,
-0.3769542872905731,
-0.7286533713340759,
-1.3627419471740723,
0.32309412956237793,
1.0903364419937134,
-0.25524747371673584,
-0.7274863123893738,
-0.21889044344425201,
1.2563185691833496,
-0.18552663922309875,
0.26269453763961... |
javascript/reference/global_objects/math/floor/index.md | JavaScript - Global Objects - Math - floor - Syntax - Parameters:
- `x`: A number. | [
-0.30904650688171387,
-0.002177221467718482,
-1.806570053100586,
-1.0713019371032715,
-0.7364014387130737,
-1.3163013458251953,
0.5326440930366516,
0.652692437171936,
0.11023278534412384,
-0.7016189694404602,
-0.8620496988296509,
0.7553145885467529,
-0.13556300103664398,
0.3900837302207947... |
javascript/reference/global_objects/math/floor/index.md | JavaScript - Global Objects - Math - floor - Syntax - Return value:
The largest integer smaller than or equal to `x`. It's the same value as `-Math.ceil(-x)`. | [
-1.2218151092529297,
0.28075188398361206,
-1.3526195287704468,
-0.6087967753410339,
-0.974535346031189,
-0.7215718626976013,
0.7973377108573914,
0.4290638267993927,
-0.5056064128875732,
-0.11672955006361008,
0.06952045112848282,
1.2731493711471558,
-0.21852116286754608,
0.5134763717651367,... |
javascript/reference/global_objects/math/floor/index.md | JavaScript - Global Objects - Math - floor - Description:
Because `floor()` is a static method of `Math`, you always use it as `Math.floor()`, rather than as a method of a `Math` object you created (`Math` is not a constructor). | [
-0.8327162265777588,
0.18471278250217438,
-1.118341326713562,
0.2481490671634674,
0.02041488140821457,
-2.1554930210113525,
0.027308089658617973,
1.1598299741744995,
-0.2944837510585785,
0.17467795312404633,
-0.41355058550834656,
0.9892894625663757,
0.4941178560256958,
0.043069057166576385... |
javascript/reference/global_objects/math/floor/index.md | JavaScript - Global Objects - Math - floor - Examples - Using Math.floor():
Example:
Math.floor(-Infinity); // -Infinity
Math.floor(-45.95); // -46
Math.floor(-45.05); // -46
Math.floor(-0); // -0
Math.floor(0); // 0
Math.floor(4); // 4
Math.floor(45.05); // 45
Math.floor(45.95); // 45
Math.floor(Infinity); // Infini... | [
-1.3966445922851562,
0.7463411688804626,
-0.7322962284088135,
0.03351225703954697,
-0.5375968217849731,
-0.8571404814720154,
0.24955351650714874,
-0.011310869827866554,
-0.21880052983760834,
-0.5750474333763123,
-0.2598896324634552,
0.8612081408500671,
0.32531121373176575,
-0.2444934248924... |
javascript/reference/global_objects/math/floor/index.md | JavaScript - Global Objects - Math - floor - Examples - Decimal adjustment:
In this example, we implement a method called `decimalAdjust()` that is an enhancement method of `Math.floor()`, `Math.ceil()`, and `Math.round()`. While the three `Math` functions always adjust the input to the units digit, `decimalAdjust` ac... | [
-0.5705311298370361,
0.20193709433078766,
-0.5888806581497192,
-0.01967480219900608,
0.35053110122680664,
-0.8711633682250977,
0.6563120484352112,
0.40257543325424194,
-0.461049884557724,
0.18469874560832977,
-0.3073274493217468,
0.7289629578590393,
-1.3339461088180542,
0.3012091815471649,... |
javascript/reference/global_objects/math/log/index.md | JavaScript - Global Objects - Math - log:
The `Math.log()` static method returns the natural logarithm (base e) of a number. That is
Example:
function getBaseLog(x, y) {
return Math.log(y) / Math.log(x);
}
// 2 x 2 x 2 = 8
console.log(getBaseLog(2, 8));
// Expected output: 3
// 5 x 5 x 5 x 5 = 625
console.log(ge... | [
0.13560082018375397,
-0.14615391194820404,
-1.844581127166748,
0.1810673326253891,
0.10691359639167786,
-1.3983047008514404,
-0.42563900351524353,
0.5678552389144897,
-0.2589423358440399,
0.0007993102772161365,
-0.7978079319000244,
0.7927568554878235,
-0.18014688789844513,
0.14528836309909... |
javascript/reference/global_objects/math/log/index.md | JavaScript - Global Objects - Math - log - Syntax:
Example:
Math.log(x) | [
0.06010511890053749,
0.17777960002422333,
-1.3961313962936401,
-0.52205491065979,
-0.9176005125045776,
-1.5178807973861694,
0.1228376179933548,
1.083604335784912,
-0.07059802114963531,
-1.3094613552093506,
-0.15312394499778748,
0.5268128514289856,
0.09167249500751495,
-0.01319883018732071,... |
javascript/reference/global_objects/math/log/index.md | JavaScript - Global Objects - Math - log - Syntax - Parameters:
- `x`: A number greater than or equal to 0. | [
-0.14844374358654022,
-0.46484702825546265,
-1.2573931217193604,
-0.6181685924530029,
-0.9227557182312012,
-1.4106959104537964,
0.38629353046417236,
0.8350618481636047,
0.2894587814807892,
-1.1299670934677124,
-0.9744622111320496,
0.07142988592386246,
-0.35848942399024963,
0.12878288328647... |
javascript/reference/global_objects/math/log/index.md | JavaScript - Global Objects - Math - log - Syntax - Return value:
The natural logarithm (base e) of `x`. If `x` is ±0, returns `-Infinity`. If `x < 0`, returns `NaN`. | [
-0.616800844669342,
0.3699505925178528,
-0.9669179916381836,
0.014336848631501198,
-0.8063836693763733,
-1.4487888813018799,
0.6468992233276367,
0.03474302962422371,
-0.27527308464050293,
0.16098247468471527,
-0.8007628917694092,
0.6476048231124878,
-0.3151102066040039,
0.28117793798446655... |
javascript/reference/global_objects/math/log/index.md | JavaScript - Global Objects - Math - log - Description:
Because `log()` is a static method of `Math`, you always use it as `Math.log()`, rather than as a method of a `Math` object you created (`Math` is not a constructor).
If you need the natural log of 2 or 10, use the constants `Math.LN2` or `Math.LN10`. If you nee... | [
-0.11110123246908188,
0.5463948249816895,
-1.850468635559082,
-0.1175425723195076,
0.01044627744704485,
-1.770804762840271,
-0.3815615773200989,
0.2729448676109314,
0.042974937707185745,
-0.020215140655636787,
-0.8415454626083374,
0.5097287893295288,
-0.14153145253658295,
-0.21305915713310... |
javascript/reference/global_objects/math/log/index.md | JavaScript - Global Objects - Math - log - Examples - Using Math.log():
Example:
Math.log(-1); // NaN
Math.log(-0); // -Infinity
Math.log(0); // -Infinity
Math.log(1); // 0
Math.log(10); // 2.302585092994046
Math.log(Infinity); // Infinity | [
-0.9847468137741089,
0.30458760261535645,
-0.4526927173137665,
0.061466969549655914,
-0.4442935585975647,
-1.3377736806869507,
0.422359824180603,
0.08174796402454376,
-0.6168873906135559,
-0.738512396812439,
-0.3681759834289551,
0.18797142803668976,
0.2773543894290924,
-0.6633864641189575,... |
javascript/reference/global_objects/math/log/index.md | JavaScript - Global Objects - Math - log - Examples - Using Math.log() with a different base:
The following function returns the logarithm of `y` with base `x` (i.e., logxy\log_x y):
Example:
function getBaseLog(x, y) {
return Math.log(y) / Math.log(x);
}
If you run `getBaseLog(10, 1000)`, it returns `2.999999999... | [
0.3460262715816498,
0.7768908739089966,
-1.6715216636657715,
0.03674070164561272,
-0.36536577343940735,
-0.7436923384666443,
-0.2946462631225586,
-0.19755393266677856,
-0.29117026925086975,
-0.8021706342697144,
-0.21097710728645325,
1.4099406003952026,
-0.11394167691469193,
0.4446721374988... |
javascript/reference/global_objects/math/sqrt2/index.md | JavaScript - Global Objects - Math - SQRT2:
The `Math.SQRT2` static data property represents the square root of 2, approximately 1.414.
Example:
function getRoot2() {
return Math.SQRT2;
}
console.log(getRoot2());
// Expected output: 1.4142135623730951 | [
-1.8807916641235352,
0.3022617995738983,
-1.0136109590530396,
-0.18917998671531677,
-0.7299275994300842,
-1.7353888750076294,
-0.5628798604011536,
-0.03528609126806259,
0.05129034444689751,
-0.20874929428100586,
-0.3597639501094818,
0.9635366201400757,
0.2562275826931,
-0.46738454699516296... |
javascript/reference/global_objects/math/sqrt2/index.md | JavaScript - Global Objects - Math - SQRT2 - Description:
`Math.SQRT2` is a constant and a more performant equivalent to `Math.sqrt(2)`.
Because `SQRT2` is a static property of `Math`, you always use it as `Math.SQRT2`, rather than as a property of a `Math` object you created (`Math` is not a constructor). | [
-1.6180537939071655,
0.3123314380645752,
-0.752265214920044,
-0.13239891827106476,
-0.22635389864444733,
-1.9221216440200806,
-0.17336782813072205,
0.798307478427887,
0.7087942361831665,
0.6495192646980286,
-0.9576637744903564,
0.9077798128128052,
0.33538269996643066,
0.02752472087740898,
... |
javascript/reference/global_objects/math/sqrt2/index.md | JavaScript - Global Objects - Math - SQRT2 - Examples - Using Math.SQRT2:
The following function returns the square root of 2:
Example:
function getRoot2() {
return Math.SQRT2;
}
getRoot2(); // 1.4142135623730951 | [
-1.753071904182434,
1.1658787727355957,
-0.7949528098106384,
-0.41702643036842346,
-1.1109867095947266,
-1.2088127136230469,
0.14764443039894104,
-0.3858465254306793,
-0.6333231925964355,
-0.616438627243042,
-0.43804365396499634,
1.0393052101135254,
-0.49976032972335815,
0.0323874205350875... |
javascript/reference/global_objects/math/abs/index.md | JavaScript - Global Objects - Math - abs:
The `Math.abs()` static method returns the absolute value of a number.
Example:
function difference(a, b) {
return Math.abs(a - b);
}
console.log(difference(3, 5));
// Expected output: 2
console.log(difference(5, 3));
// Expected output: 2
console.log(difference(1.23456... | [
-0.0382615365087986,
-0.5540560483932495,
-1.4331367015838623,
-0.2182614952325821,
-0.06657871603965759,
-1.3223482370376587,
0.5637640953063965,
0.9560800194740295,
0.41334637999534607,
0.17462706565856934,
-0.645657479763031,
0.617766797542572,
0.27955156564712524,
0.4320646822452545,
... |
javascript/reference/global_objects/math/abs/index.md | JavaScript - Global Objects - Math - abs - Syntax:
Example:
Math.abs(x) | [
0.3399026393890381,
0.1481596827507019,
-1.1789743900299072,
-0.5736503005027771,
-0.8494426608085632,
-1.2409687042236328,
0.7510173320770264,
0.9584805965423584,
0.3791695833206177,
-0.40515461564064026,
-0.7904008626937866,
0.6344162225723267,
0.012901595793664455,
0.17702272534370422,
... |
javascript/reference/global_objects/math/abs/index.md | JavaScript - Global Objects - Math - abs - Syntax - Parameters:
- `x`: A number. | [
0.49503445625305176,
-0.4173656404018402,
-1.7790873050689697,
-0.9795952439308167,
-0.8924338221549988,
-1.2013983726501465,
0.8176670074462891,
0.6262219548225403,
0.5772625207901001,
-0.4871245324611664,
-1.4025942087173462,
0.2579864263534546,
0.12463981658220291,
0.32123157382011414,
... |
javascript/reference/global_objects/math/abs/index.md | JavaScript - Global Objects - Math - abs - Syntax - Return value:
The absolute value of `x`. If `x` is negative or `-0`, returns its opposite number `-x` (which is non-negative). Otherwise, returns `x` itself. The result is therefore always a positive number or `0`. | [
-0.5850116610527039,
0.22074294090270996,
-1.0520440340042114,
0.21959535777568817,
-0.6185272932052612,
-1.4112675189971924,
1.5763431787490845,
0.6478394269943237,
0.3636484444141388,
0.4472312927246094,
-0.8674764633178711,
0.4818097651004791,
-0.15776629745960236,
0.6666058301925659,
... |
javascript/reference/global_objects/math/abs/index.md | JavaScript - Global Objects - Math - abs - Description:
Because `abs()` is a static method of `Math`, you always use it as `Math.abs()`, rather than as a method of a `Math` object you created (`Math` is not a constructor). | [
-0.012742442078888416,
-0.4678370952606201,
-0.8855792284011841,
0.33752405643463135,
-0.024356551468372345,
-2.1514570713043213,
0.34275317192077637,
0.8660486340522766,
0.33690905570983887,
0.612526535987854,
-0.9902278780937195,
0.6162521243095398,
0.7646320462226868,
-0.068801313638687... |
javascript/reference/global_objects/math/abs/index.md | JavaScript - Global Objects - Math - abs - Examples - Using Math.abs():
Example:
Math.abs(-Infinity); // Infinity
Math.abs(-1); // 1
Math.abs(-0); // 0
Math.abs(0); // 0
Math.abs(1); // 1
Math.abs(Infinity); // Infinity | [
-0.3621710240840912,
0.3916266858577728,
-0.6028928160667419,
0.2264377474784851,
-0.41959381103515625,
-1.3465855121612549,
0.9785115718841553,
0.20335416495800018,
0.31383800506591797,
-0.23145292699337006,
-0.818939745426178,
0.09003155678510666,
0.6642615795135498,
-0.35088595747947693... |
javascript/reference/global_objects/math/abs/index.md | JavaScript - Global Objects - Math - abs - Examples - Coercion of parameter:
`Math.abs()` coerces its parameter to a number. Non-coercible values will become `NaN`, making `Math.abs()` also return `NaN`.
Example:
Math.abs("-1"); // 1
Math.abs(-2); // 2
Math.abs(null); // 0
Math.abs(""); // 0
Math.abs([]); // 0
Math.... | [
-0.12236299365758896,
0.42184212803840637,
-0.6030431389808655,
-0.07110479474067688,
-0.11035525798797607,
-0.6508004069328308,
0.9142330288887024,
0.3315354883670807,
-0.4149678945541382,
0.7453621625900269,
-1.181566834449768,
0.0837097018957138,
0.026934724301099777,
-0.575613617897033... |
javascript/reference/global_objects/math/atan2/index.md | JavaScript - Global Objects - Math - atan2:
The `Math.atan2()` static method returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for `Math.atan2(y, x)`.
Example:
function calcAngleDegrees(x, y) {
return (Math.atan2(y, x) * 180) / Math.PI;
}
console.... | [
-0.3581940233707428,
-0.17759540677070618,
-1.4799320697784424,
-0.7671568989753723,
-0.21148991584777832,
-0.45448657870292664,
0.07641313970088959,
0.3468138575553894,
0.20741014182567596,
0.27198243141174316,
-0.22373166680335999,
0.5064605474472046,
-0.07091005146503448,
0.374363034963... |
javascript/reference/global_objects/math/atan2/index.md | JavaScript - Global Objects - Math - atan2 - Syntax:
Example:
Math.atan2(y, x) | [
0.19565658271312714,
0.6635823249816895,
-0.876815915107727,
-0.4174816608428955,
-1.1265863180160522,
-1.3280267715454102,
-0.14754946529865265,
0.844621479511261,
-0.1334216594696045,
-0.9360105395317078,
-0.5231407284736633,
0.2439221441745758,
-0.6713847517967224,
0.10062766075134277,
... |
javascript/reference/global_objects/math/atan2/index.md | JavaScript - Global Objects - Math - atan2 - Syntax - Parameters:
- `y`: The y coordinate of the point.
- `x`: The x coordinate of the point. | [
0.6249479055404663,
-0.023359039798378944,
-1.2218445539474487,
-0.9179290533065796,
-0.4535175859928131,
-1.3709462881088257,
0.00747407041490078,
0.5422961115837097,
0.7399600148200989,
-0.5726963877677917,
-0.9373690485954285,
0.4039638042449951,
-0.296482115983963,
0.5422736406326294,
... |
javascript/reference/global_objects/math/atan2/index.md | JavaScript - Global Objects - Math - atan2 - Syntax - Return value:
The angle in radians (between -π and π, inclusive) between the positive x-axis and the ray from (0, 0) to the point (x, y). | [
-0.6801531910896301,
0.24100233614444733,
-0.9262957572937012,
-0.7761961221694946,
-0.600861132144928,
-0.2517673373222351,
0.23969802260398865,
0.489676833152771,
0.4572656750679016,
0.07922805845737457,
-0.43408510088920593,
0.6055083870887756,
-0.02326826937496662,
0.524958074092865,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.