Operator:x -= yMeaning:x = x - y Examples Using subtraction assignment // Assuming the following variable // bar = 5 bar -= 2 // 3 bar -= 'foo' // NaN Specifications Specification ECMAScript (ECMA-262) The definition of 'Assignment operators' in that specification. ...
Spread operator No support 49.0 34.0 (34) ? ? ? 49.0 [1] Requires "Enable experimental Javascript features" to be enabled under `about:flags` Firefox-specific notes Firefox provided a non-standard language extension in JS1.7 for destructuring. This extension has been removed in Gecko 40 (Firef...
Become a caniuse Patron to support the site and disable ads for only $1/month! or Log in Site links Home Feature index Browser usage table Feature suggestion list Caniuse data on GitHub Legend Green ✅ = Supported Red ❌ = Not supported Greenish yellow ◐ = Partial suppo...
JavaScript operator: Division assignment (`x /= y`) Global usage 97.41% + 0% = 97.41% IE ✅ 6 - 10: Supported ✅ 11: Supported Edge ✅ 12 - 130: Supported ✅ 131: Supported Firefox ✅ 2 - 132: Supported ✅ 133: Supported ✅ 134 - 136: Supported Chrome ✅ 4 - 130...
Splitting off from #35, this proposal is for just one new operator: :=, the block assignment operator. So the great advantage of let/const is its block-scoping, i.e.: let a = 1; if (true) { let b = 2; } console.log(b); // undefined This ...
You can also use the ternary operator. This provides a compact if else representation.a === 1 ? console.log(1) : console.log('not 1');You can use boolean operations in the expression to create complex predicates. Common boolean operators include && (and), || (or), and ! (not).if...
To make "bar" a declared variable, you can add thevarkeyword in front of it. function foo() { "use strict"; var bar = true; } foo(); See also Strict mode 文档标签和贡献者 标签: Errors JavaScript ReferenceError Strict Mode 此页面的贡献者:fscholz ...
In theifstatement, you want to use an equality operator (===), and for the string concatenation, the plus (+) operator is needed. js if(Math.PI+1===3||Math.PI+1===4){console.log("no way!");}conststr="Hello, "+"from the "+"other side!"; ...
JavaScript operator: Exponentiation assignment (`x **= y`) Global usage 96.42% + 0% = 96.42% IE ❌ 6 - 10: Not supported ❌ 11: Not supported Edge ❌ 12 - 13: Not supported ✅ 14 - 130: Supported ✅ 131: Supported Firefox ❌ 2 - 51: Not supported ✅ 52 - 132: ...
To make "bar" a declared variable, you can add thevarkeyword in front of it. function foo() { "use strict"; var bar = true; } foo(); See also Strict mode Document Tags and Contributors Tags: Errors JavaScript ReferenceError Strict Mode ...