es6.number.to-precision.js 613 B

123456789101112131415161718
  1. 'use strict';
  2. var $export = require('./_export');
  3. var $fails = require('./_fails');
  4. var aNumberValue = require('./_a-number-value');
  5. var $toPrecision = 1.0.toPrecision;
  6. $export($export.P + $export.F * ($fails(function () {
  7. // IE7-
  8. return $toPrecision.call(1, undefined) !== '1';
  9. }) || !$fails(function () {
  10. // V8 ~ Android 4.3-
  11. $toPrecision.call({});
  12. })), 'Number', {
  13. toPrecision: function toPrecision(precision) {
  14. var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!');
  15. return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision);
  16. }
  17. });