--- title: 단항 부정 (-) slug: Web/JavaScript/Reference/Operators/Unary_negation tags: - JavaScript - Language feature - Operator - Reference browser-compat: javascript.operators.unary_negation ---
단항 부정 연산자(-
)는 피연산자 앞에 위치하며, 피연산자의 부호를 부정합니다. 즉 양수는 음수로, 음수는 양수로 바꿉니다.
-x
const x = 3; const y = -x; // y = -3 // x = 3
단항 부정 연산자는 숫자가 아닌 값을 숫자로 변환할 수 있습니다.
const x = "4"; const y = -x; // y = -4
{{Compat}}