Shelby115
Shelby115

Reputation: 2867

Are there times in which an empty string is not equal to an empty string in JavaScript?

I just seen this code snippet: '' === '' ? null : ('' === '*' ? '*' : ('').split(','));

Is there ever a time in which '' === '' is not true?

Upvotes: 2

Views: 119

Answers (1)

Bergi
Bergi

Reputation: 664395

Is there ever a time in which '' === '' is not true?

No, there is not.

This whole code snippet doesn't make too much sense, my guess would be that it is dynamically generated code and the string literals are filled in with some kind of templating mechanism - in this case they were filled with the empty string. Of course the conditions should better have been evaluated in the generator, but maybe the used engine didn't support this.

Upvotes: 2

Related Questions