JavaScript Type Conversion – A Quick Test

JavaScript is a dynamically typed language. To test your knowledge about this, here are some expressions:

a = '24' - 3;
b = '24' + 3;
c = '24' - '3';
d = '24' + '3';

Now after executing this piece of code, what’s the values of a, b, c, and d? Numbers? Strings? Or NaN’s?

OK. Bring out Firebug and execute the statements to see the results. (What is Firebug? Get it now. It’s awesome!)

Were you right? Now you should understand some type conversion rules of JavaScript.

Leave a comment

Your email address will not be published. Required fields are marked *

Prove your intelligence before hitting * Time limit is exhausted. Please reload CAPTCHA.