+ 1

Datatypes in js

Can somebody explain how do the datatypes link to the functions.For example sometimes when i declare a variable and give it a string function it doesn't work until i convert it manually to string datatype.Why does this happen?

13th Oct 2017, 4:30 PM
Satvik A
Satvik A - avatar
1 Answer
+ 1
The data type is based on the last assignment to the variable. n = 5+3; makes n an integer ignoring the fact that it was initialized as a string with n = "12";
13th Oct 2017, 4:37 PM
John Wells
John Wells - avatar