Number.prototype.valueOf()
Метод valueOf()
вертає загорнуте примітивне значення об'єкта Number
.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Синтаксис
numObj.valueOf()
Значення, що вертається
Число, яке відображає примітивне значення вказаного об'єкта Number
.
Опис
Цей метод, зазвичай, викликається внутрішньо у JavaScript, а не явно у коді.
Приклади
Використання valueOf
let numObj = new Number(10)
console.log(typeof numObj) // object
let num = numObj.valueOf()
console.log(num) // 10
console.log(typeof num) // number
Специфікації
Специфікація |
---|
ECMAScript (ECMA-262) The definition of 'Number.prototype.valueOf' in that specification. |
Сумісність з веб-переглядачами
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.