JS: Number.prototype
What is Number.prototype
Number.prototype is the value of the property key "prototype" of the function Number.
〔see Number Object〕
console.assert(Object.hasOwn(Number, "prototype"));
Type
Type of Number.prototype is Object
.
console.assert(typeof Number.prototype === "object");
Number.prototype is actually a number. It has a value of 0.
console.assert(Reflect.apply(Object.prototype.toString, Number.prototype, []) === "[object Number]"); console.assert(Reflect.apply(Number.prototype.valueOf, Number.prototype, []) === 0);
Parent
Parent of Number.prototype is Object.prototype
.
console.assert(Reflect.getPrototypeOf(Number.prototype) === Object.prototype);
Purpose
Purpose of Number.prototype is to provide methods and properties useful for all number objects.
Properties
Convert to string
- JS: Number.prototype.toFixed
- JS: Number.prototype.toPrecision
- JS: Number.prototype.toExponential
- JS: Number.prototype.toString (Number to String)
- JS: Number.prototype.toLocaleString
Other
Number.prototype.constructor-
Value is
Number. 〔see Number Object〕console.assert(Number.prototype.constructor === Number); Number.prototype.valueOf-
Return the number as primitive value.
console.assert((new Number(3)).valueOf() === 3);
JavaScript. Number
- JS: Number
- JS: Number Input. Binary, Hexadecimal, Octal, Etc
- JS: Assignment Operators
- JS: Math Operators
- JS: Number Comparison Operators
- JS: Convert String and Number
- JS: Convert Decimal, Hexadecimal
- JS: Convert Decimal, Binary
- JS: Format Number
- JS: Random Integer Range Function 📜
- JS: Number (class)
- JS: Number Constructor
- JS: Number.prototype
- JS: Math (namespace)