A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Unary_negation below:

ë‹¨í• ë¶€ì • (-) - JavaScript

단항 부정 (-)

Baseline Widely available

단항 부정 연산자(-)는 피연산자 앞에 위치하며, 피연산자의 부호를 부정합니다. 즉 양수는 음수로, 음수는 양수로 바꿉니다.

시도해 보기
const x = 4;
const y = -x;

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

const a = "4";
const b = -a;

console.log(b);
// Expected output: -4
구문 예제 숫자 부정하기
const x = 3;
const y = -x;

// y = -3
// x = 3
숫자가 아닌 값을 부정하기

단항 부정 연산자는 숫자가 아닌 값을 숫자로 변환할 수 있습니다.

const x = "4";
const y = -x;

// y = -4
명세 브라우저 호환성 같이 보기

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4