Here is the piece of code
str = "a,b,c";
name = str.split(",");
The name
variable shows up as 'object' type in Firefox and 'string' type in chrome
Why is that happening ?
Here is the jsfiddle http://jsfiddle.net/XujYT/17/
Also the name
variable stores the value "a,b,c"
instead of the split array in chrome
http://jsfiddle.net/XujYT/23/
Because name
is a global variable used by chrome, and it’s not possible to override it without unexpected results. Try:
var name = str.split(","); // always use var for local variables!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With