hi i want to a one line of code (without using loop) in javascript to find the if there is semicolon in a string... please help if any one knows
2 Answers
myStringVal.indexOf(";") !== -1;
For more information, check out the documentation for String.prototype.indexOf().
1 Comment
T.J. Crowder
+1 (although I always advocate
>= 0 rather than != -1 out of paranoia; but the spec does specifically say -1 for not found, so...) But please refer people to the specification. w3schools is incomplete at best.