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 /
Also the name
variable stores the value "a,b,c"
instead of the split array in chrome
/
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/XujYT/17/
Also the name
variable stores the value "a,b,c"
instead of the split array in chrome
http://jsfiddle/XujYT/23/
1 Answer
Reset to default 13Because 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!