Answer the question
In order to leave comments, you need to log in
Why does javascript do this?
What happens if you run this code?
name = "string"
name = name.split('');
name_spliced = name.splice(1,1);
console.log(name_spliced)
["t"]
? not_name = "string"
not_name = not_name.split('');
not_name_spliced = not_name.splice(1,1);
console.log(not_name_spliced)
["t"]
name.split('')
js could do, only then, for some reason, it became a string with commas, not an array. Answer the question
In order to leave comments, you need to log in
the point is that name is a property of the global window object, and it can only be a string;
when assigning any value, the toString () function is called.
The same situation in principle with status.
Always use the var keyword and you won't have these problems :)
var name = "string";
name = name.split('');
name_spliced = name.splice(1,1);
console.log(name_spliced)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question