function NumberToPrecisionJS(precision) {
  var x = this;
  if (!IS_NUMBER(this)) {
    if (!IS_NUMBER_WRAPPER(this)) {
      throw MakeTypeError(kIncompatibleMethodReceiver,
                          "Number.prototype.toPrecision", this);
    }
    // Get the value of this number in case it's an object.
    x = %_ValueOf(this);
  }
  if (IS_UNDEFINED(precision)) return TO_STRING(x);
  var p = TO_INTEGER(precision);

  if (NUMBER_IS_NAN(x)) return "NaN";
  if (x == INFINITY) return "Infinity";
  if (x == -INFINITY) return "-Infinity";

  if (p < 1 || p > 21) {
    throw MakeRangeError(kToPrecisionFormatRange);
  }
  return %NumberToPrecision(x, p);
}
function NumberToPrecisionJS(precision) {
  var x = this;
  if (!IS_NUMBER(this)) {
    if (!IS_NUMBER_WRAPPER(this)) {
      throw MakeTypeError(kIncompatibleMethodReceiver,
                          "Number.prototype.toPrecision", this);
    }
    
    x = %_ValueOf(this);
  }
  if (IS_UNDEFINED(precision)) return TO_STRING(x);
  var p = TO_INTEGER(precision);

  if (NUMBER_IS_NAN(x)) return "NaN";
  if (x == INFINITY) return "Infinity";
  if (x == -INFINITY) return "-Infinity";

  if (p < 1 || p > 21) {
    throw MakeRangeError(kToPrecisionFormatRange);
  }
  return %NumberToPrecision(x, p);
}
function NumberToPrecisionJS ( precision ) { var x = this ; if ( ! IS_NUMBER ( this ) ) { if ( ! IS_NUMBER_WRAPPER ( this ) ) { throw MakeTypeError ( kIncompatibleMethodReceiver , "Number.prototype.toPrecision" , this ) ; } // Get the value of this number in case it's an object. x = % _ValueOf ( this ) ; } if ( IS_UNDEFINED ( precision ) ) return TO_STRING ( x ) ; var p = TO_INTEGER ( precision ) ; if ( NUMBER_IS_NAN ( x ) ) return "NaN" ; if ( x == INFINITY ) return "Infinity" ; if ( x == - INFINITY ) return "-Infinity" ; if ( p < 1 || p > 21 ) { throw MakeRangeError ( kToPrecisionFormatRange ) ; } return % NumberToPrecision ( x , p ) ; }
ES6 20.1.3.5 Number.prototype.toPrecision(precision)
ES6 20 . 1 . 3 . 5 Number . prototype . toPrecision ( precision )