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

(/=) - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

(/=)

Baseline

20157

(/=) 2

let a = 3;

a /= 2;
console.log(a);
// : 1.5

a /= 0;
console.log(a);
// : Infinity

a /= "hello";
console.log(a);
// : NaN

js
x /= y

x /= y x = x / y x

js
let bar = 5;

bar /= 2; // 2.5
bar /= 2; // 1.25
bar /= 0; // Infinity

js
let bar = 5;
bar /= "2"; // 2.5
bar /= "foo"; // NaN

js
let foo = 3n;
foo /= 2n; // 1n
foo /= 2n; // 0n

foo /= 0n; // RangeError: BigInt division by zero
foo /= 1; // TypeError: Cannot mix BigInt and other types, use explicit conversions

ECMAScript 2027 LanguageSpecification
# sec-assignment-operators


Web Proxy Viewer  |  New URL  |  Original Page