| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Operators/Decrement | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since 20157.
--
let x = 3;
const y = x--;
console.log(`x:${x}, y:${y}`);
// Expected output: "x:2, y:3"
let a = 3;
const b = --a;
console.log(`a:${a}, b:${b}`);
// Expected output: "a:2, b:2"
x--
--x
x--
--x
let x = 3;
y = x--;
// y = 3
// x = 2
let a = 2;
b = --a;
// a = 1
// b = 1
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-postfix-decrement-operator |
This page was last modified on 2025716 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |