JavaScript in 2 Days – Operators
In JavaScript, operators are symbols or keywords that allow you to perform operations on values and variables. They are essential for building expressions and the logic of your programs.
Types of operators in JavaScript
1. Arithmetic: perform mathematical operations such as addition, subtraction, multiplication, division, modulus, exponent, and increments and decrements. Example: let a = 10, b = 3; console.log(a + b); // 13 console.log(a % b); // 1
2. Assignment: assign values to variables using = and shortcuts like +=, -=, *=, /=, %=, **=. Example: let x = 5; x += 3; // now x is 8
3. Comparison: compare two values and return true or false. Operators: ==, !=, ===, !==, >, <, >=, <=. Example: console.log(5 == String(5)); // true console.log(5 === String(5)); // false
4. Logical: combine boolean conditions using the operators &&, ||, ! to build compound expressions. Example: true && false // false true || false // true !true // false
5. Bitwise operations: work bit by bit with operators like &, |, ^, ~, <<, >>. Example: console.log(5 & 1); // 1
6. String operators: concatenate and combine text with + and +=. Conceptual example: let greeting = name + surname // concatenates name and surname
7. Ternary: short form for if else with the syntax condition ? expr1 : expr2. Example: let max = a > b ? a : b
8. Type checking and special operators: typeof to know the type, instanceof to check prototypes, delete to remove properties, and void to evaluate expressions without returning a value.
Arithmetic operators
Arithmetic operators allow you to perform calculations on numeric values. Practical example: let a = 10, b = 3; console.log(a + b); // 13 console.log(a - b); // 7 console.log(a * b); // 30 console.log(a / b); // 3.3333333333333335 console.log(a % b); // 1 a++; b--;
Assignment operators
They are used to assign and update values in variables concisely. Example: let x = 10; x -= 2; // x is now 8 x *= 3; // x is now 24
Comparison operators
They are used to compare values and return booleans. It is important to distinguish between loose and strict equality. Example: console.log(0 == false); // true console.log(0 === false); // false
Logical operators
They allow you to combine conditions in control structures. Example: let cond = (a > 0) && (b > 0); if(cond) console.log('both positive');
Practical example JavaScript Calculator
function add(num1, num2) { console.log(num1 + num2) } function sub(num1, num2) { console.log(num1 - num2) } function mul(num1, num2) { console.log(num1 * num2) } function div(num1, num2) { console.log(num1 / num2) } function mod(num1, num2) { console.log(num1 % num2) } add(5, 5) sub(5, 2) mul(3, 7) div(10, 2) mod(2, 2)
Quick tips
Use === and !== to avoid implicit type conversions. Choose short operators like += to keep code clean. Be careful with operator precedence and use parentheses to avoid ambiguity.
About Q2BSTUDIO
Q2BSTUDIO is a custom software and application development company specialized in artificial intelligence, cybersecurity, and cloud solutions. We offer custom software and custom applications for companies that need to transform processes through AI for businesses, AI agents, and business intelligence solutions. Our services include AWS and Azure cloud services, Power BI integration, business intelligence services consulting, implementation of artificial intelligence models, and cybersecurity strategies. We adapt each project to the client's needs with agile methodologies and a focus on security and scalability.
Featured services
custom applications, custom software, artificial intelligence, AI for businesses, AI agents, cybersecurity, AWS and Azure cloud services, business intelligence services, Power BI
If you are looking to modernize your technology architecture, develop a specific application, or integrate artificial intelligence capabilities into your processes, Q2BSTUDIO offers technical expertise and strategic support to take your project from idea to production.
Contact Q2BSTUDIO for an initial assessment and discover how we can accelerate your digital transformation with secure, scalable, results-oriented solutions.





