Number.prototype.valueOf()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
valueOf() ë©ìëë Number ê°ì²´ê° ê°ì¼(wrapped) ìì ê°ì ë°íí©ëë¤.
ìëí´ ë³´ê¸°
const numObj = new Number(42);
console.log(typeof numObj);
// Expected output: "object"
const num = numObj.valueOf();
console.log(num);
// Expected output: 42
console.log(typeof num);
// Expected output: "number"
구문
js
numObj.valueOf();
ë°í ê°
Number ê°ì²´ì ìì ê°.
ì¤ëª
valueOf() ë©ìëë ë³´íµ JavaScriptì ìí´ ë´ë¶ì ì¼ë¡ í¸ì¶ëê³ , ì¹ ì½ëììë ëª
ìì ì¼ë¡ í¸ì¶íì§ ììµëë¤.
ìì
>valueOf ì¬ì©í기
js
var numObj = new Number(10);
console.log(typeof numObj); // object
var num = numObj.valueOf();
console.log(num); // 10
console.log(typeof num); // number
ëª ì¸
| Specification |
|---|
| ECMAScript® 2027 Language Specification > # sec-number.prototype.valueof > |