shlogg · Early preview
Ranjith Srt @ranjithsrt

Type Conversion In JavaScript Explained

Type conversion in JavaScript: explicit (e.g. `Number()` ) vs implicit (automatic coercion) and its effects on equality checks and arithmetic operations.

Type Conversion (Manually)

    
    

    
    




Type conversion (also known as type casting) is when you explicitly convert a
value from one type to another. JavaScript provides several functions for this purpose.

Type Conversion:

    
    

    
    





String to Number:

    
    

    
    






let strNum ="123" ; //str
let num = Number(strNum);
   123  =  123    "123"

console.log(num); //123
console.log(typeof num); //number


    
    

    
    





Number to String:

    
    

    
    






let num=456;
let str =String(num);
         "456"   456

console.log(num); //"459...