Global Trend Radar
Web: www.geeksforgeeks.org US web_search 2026-05-01 05:38

JavaScriptの剰余代入(%=)演算子

原題: JavaScript Remainder Assignment (%=) Operator - GeeksforGeeks

元記事を開く →

分析結果

カテゴリ
AI
重要度
54
トレンドスコア
18
要約
JavaScriptの剰余代入演算子(%=)は、左辺の変数に右辺の値を割った余りを代入するために使用されます。この演算子は、変数の値を更新する際に便利で、コードを簡潔に保つことができます。例えば、x %= yはx = x % yと同じ意味です。この演算子を使うことで、数値の計算を効率的に行うことができます。
キーワード
JavaScript Remainder Assignment(%=) Operator - GeeksforGeeks Courses Tutorials Interview Prep JS Tutorial Web Tutorial A to Z Guide Projects OOP DOM Set Map Math Number Boolean Exercise JavaScript Remainder Assignment(%=) Operator Last Updated : 23 Jul, 2025 JavaScript remainder assignment operator ( %= ) assigns the remainder to the variable after dividing a variable by the value of the right operand. Syntax: Operator: x %= y Meaning: x = x % y Below example illustrate the Remainder assignment(%=) Operator in JavaScript: Example 1: The following example demonstrates if the given number is divisible by 4 or if it's an even or odd number. JavaScript let num = 16 ; // Test if its divisible by 4 if ( num % 4 == 0 ) { console . log ( true ); } // Test for even number if ( num % 2 == 0 ) { console . log ( true ); } else { console . log ( false ); } // Test for odd number if ( ! ( num % 2 == 0 )) { console . log ( true ); } else { console . log ( false ); }; Output: true true false Example 2: The following example demonstrates if the given number is divisible by 2, 0, and world. JavaScript let gfg = 3 ; console . log (( gfg %= 2 )); console . log (( gfg %= 0 )); console . log (( gfg %= "world" )); Output: 1 Nan Nan We have a complete list of Javascript Assignment Operators, to check those please go through the Javascript Assignment Operators List article. Comment Article Tags: Article Tags: JavaScript Web Technologies javascript-operators Explore JavaScript Basics Introduction 3 min read Variables 5 min read Operators 4 min read Control Statements 4 min read Array & String Arrays 7 min read Array Methods 7 min read String 5 min read String Methods 9 min read Function & Object Functions 4 min read Function Expression 3 min read Function Overloading 4 min read Objects 4 min read Constructors 4 min read OOP OOP 3 min read Classes & Objects 4 min read Access Modifiers 5 min read Constructor 7 min read Asynchronous JavaScript Asynchronous 2 min read Callbacks 4 min read Promises 4 min read Event Loop 3 min read Async Await Fuction 3 min read Exception Handling Error and Exceptional Handling 5 min read Errors Throw & Try to Catch 2 min read Custom Errors 2 min read TypeError Invalid Array.prototype.sort argument 1 min read DOM DOM 8 min read DOM Elements 3 min read Custom Events 4 min read Addeventlistener 9 min read Advanced Topics Closure 4 min read Hoisting 6 min read Scope 3 min read Higher Order Functions 7 min read Debugging 3 min read

類似記事(ベクトル近傍)