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

(--) - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

(--)

Baseline

20157

(--) 1

let x = 3;
const y = x--;

console.log(`x:${x}, y:${y}`);
// : "x:2, y:3"

let a = 3;
const b = --a;

console.log(`a:${a}, b:${b}`);
// : "a:2, b:2"

js
x--
--x

-- 2

x--

--x

--x

js
--(--x); // SyntaxError: Invalid left-hand side expression in prefix operation

js
let x = 3;
const y = x--;
// x  2y  3

let x2 = 3n;
const y2 = x2--;
// x2  2ny2  3n

js
let x = 3;
const y = --x;
// x  2; y = 2

let x2 = 3n;
const y2 = --x2;
// x2  2n; y2  2n

ECMAScript 2027 LanguageSpecification
# sec-postfix-decrement-operator


Web Proxy Viewer  |  New URL  |  Original Page