Type Coercion in Javascript
Samuel Majok
Posted on June 4, 2023
Interesting fact...
I was asked about this type coercion in an interview and I said that question was irrelevent since it had no use in my day today operations and the interviewer literally asked me to just define it and I was left fidgetting....
Yes, you need to have a very strong grasp with the basics of javascript apparently.
Infact, after diving deep into the topic of type coercion, I learnt so much that I didn't know and how important it was...
- - - - - - > #hashtag LEARN YOUR BASICS
TYPE COERCION....
Definition: This is the automatic or implicit conversion of values from one type to another
Example....
let a = 1;
let b = "5";
let c = a + b;
console.log(c);
// the value of c will be 15
// this is because addition converts numbers to string
let d = 5 - 1;
console.log(d);
// the value of d will be 4
// this is because subtraction converts strings to numbers
π πͺ π
π©
Samuel Majok
Posted on June 4, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
privacy Caught in the Crunch My Journey from Snacks to 2 Million Exposed Users Privacy
November 30, 2024