JavaScript Coding Day 13 | JavaScript Operators : Comparison Ternary Logical
JavaScript Operators : Comparison Ternary Logical Watch the lesson tutorial 🔻 Operators are the building blocks of any programming language. In JavaScript, they allow us to perform logic, math, and comparisons. Below, we break down three essential types: Comparison, Ternary, and Logical operators. 1. Comparison Operators Comparison operators are used to compare two values. They always return a boolean value: either true or false . The Code: JavaScript var x = 6 ; var y = 2 ; // 1. Loose Equality (==) console .log(x == y); // Output: false // Explanation: Checks if 6 is equal to 2. It is not. // 2. Strict Equality (===) console .log(x === y); // Output: false // Explanation: Checks if value AND data type are the same. // 3. Inequality (!=) console .log(x != y); // Output: true // Explanation: Checks if x is NOT equal to y. Since 6 is not 2, this is true. Detailed Explanation: == vs === : This is a common interview question! == checks only the value (it ...