Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
757 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 | var $ = require('../internals/export');
|
---|
| 3 | var fails = require('../internals/fails');
|
---|
| 4 | var thisNumberValue = require('../internals/this-number-value');
|
---|
| 5 |
|
---|
| 6 | var nativeToPrecision = 1.0.toPrecision;
|
---|
| 7 |
|
---|
| 8 | var FORCED = fails(function () {
|
---|
| 9 | // IE7-
|
---|
| 10 | return nativeToPrecision.call(1, undefined) !== '1';
|
---|
| 11 | }) || !fails(function () {
|
---|
| 12 | // V8 ~ Android 4.3-
|
---|
| 13 | nativeToPrecision.call({});
|
---|
| 14 | });
|
---|
| 15 |
|
---|
| 16 | // `Number.prototype.toPrecision` method
|
---|
| 17 | // https://tc39.es/ecma262/#sec-number.prototype.toprecision
|
---|
| 18 | $({ target: 'Number', proto: true, forced: FORCED }, {
|
---|
| 19 | toPrecision: function toPrecision(precision) {
|
---|
| 20 | return precision === undefined
|
---|
| 21 | ? nativeToPrecision.call(thisNumberValue(this))
|
---|
| 22 | : nativeToPrecision.call(thisNumberValue(this), precision);
|
---|
| 23 | }
|
---|
| 24 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.