4

What is the proper behaviour of

"test".split("/")

Should the result be ["test"] or undefined? I am asking because I get different results for two different javascript engines. Most browsers seem to return ["test"], so I wonder if the deviating behaviour should be considered a bug.

1
  • 1
    What browser gives different behaviour? Commented May 17, 2013 at 9:31

1 Answer 1

3

The ES5 specification for String.prototype.split does not allow for any return result other than an array, so undefined is not correct.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.