Debugging in JS
Identifies and fixes code error, bugs , issues
Makes sure the program runs correctly.
Tools: console, debugger, DevTools etc.
Common Debugging Tools in
JavaScript
Console Methods
Debugger Keyword
Browser Developer Tools
Try...Catch
Try-Catch
Handle errors safely without crashing your program
Provides error messages.
Useful for:
API calls
JSON parsing
User input validation
File handling
try → risky code.
catch → handles error.
[Link] → shows error detail.
finally → always runs (cleanup
try {
// code that may throw an error
} catch (error) {
// code to handle the error
} finally {
// (optional) code that always runs
}
Operators in JavaScript
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Increment/Decrement
Ternary Operator
Type Operators
Arithmetic Operators
Used for mathematical calculations.
Operator Meaning Example Result
+ Addition 5+3 8
- Subtraction 5-3 2
* Multiplication 5*3 15
/ Division 10 / 2 5
Modulus
% 10 % 3 1
(remainder)
** Exponentiation 2 ** 3 8
Assignment Operators
Assign values to variables.
Operator Example Meaning
= x=5 Assign 5 to x
+= x += 3 x=x+3
-= x -= 2 x=x-2
*= x *= 4 x=x*4
/= x /= 2 x=x/2
%= x %= 3 x=x%3
Comparison Operators
Used to compare values. Returns true or false.
Operator Example Result
true (checks only
== 5 == "5"
value)
false (checks value +
=== 5 === "5"
type)
!= 5 != "5" false
!== 5 !== "5" true
> 10 > 5 true
< 10 < 5 false
>= 10 >= 10 true
<= 3 <= 5 true
Logical Operators
Used for conditions.
Operator Example Result
&& (AND) (5 > 2 && 10 > 5) true
|| ` (OR)
! (NOT) !(5 > 2) false
Increment / Decrement
Increase or decrease by 1;
Operator Example Meaning
Increase by 1 (post-
++ x++
increment)
Decrease by 1 (post-
-- x--
decrement)
++x ++x Increase first, then use
Decrease first, then
--x --x
use
Date Object
Helps with date and time values
Create , formats and manipulate date and time
Retrieving Date Components
Provide access to date components
Formatting Dates
Formats into human readable
let date3 = new Date();
[Link]([Link]()); // Thu Oct 02 2025
[Link]([Link]()); // 12:45:30
GMT+0500
[Link]([Link]()); // 2025-10-
02T07:45:30.000Z
[Link]([Link]()); // 10/2/2025
(depends on locale)
[Link]([Link]()); // 12:45:30 PM