Affectation après soustraction (-=)

L'opérateur d'affectation après soustraction (-=) calcule la soustraction de l'opérande gauche par l'opérande droit puis affecte le résultat à la variable représentée par l'opérande gauche.

Exemple interactif

Syntaxe

js
Opérateur: x -= y;
Signification: x = x - y;

Exemples

Utiliser l'opérateur de soustraction et d'affectation

js
let truc = 5;
truc -= 2; // 3
truc -= "toto"; // NaN

Spécifications

Specification
ECMAScript Language Specification
# sec-assignment-operators

Compatibilité des navigateurs

BCD tables only load in the browser

Voir aussi