[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Unary_plus [Back]  [Original]

(+) - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

(+)

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.

(+) , .

In this article

const x = 1;
const y = -1;

console.log(+x);
// Expected output: 1

console.log(+y);
// Expected output: -1

console.log(+"");
// Expected output: 0

console.log(+true);
// Expected output: 1

console.log(+false);
// Expected output: 0

console.log(+"hello");
// Expected output: NaN

js
+x;

(-) , . . true, false null . 10 16(0x ) . (16 ). BigInt TypeError . NaN .

js
const x = 1;
const y = -1;

console.log(+x);
// 1
console.log(+y);
// -1

js
+true; // 1
+false; // 0
+null; // 0
+function (val) {
  return val;
}; // NaN
+1n; // TypeError : BigInt     

Specification
ECMAScript 2027 LanguageSpecification
# sec-unary-plus-operator


Web Proxy Viewer  |  New URL  |  Original Page