I am trying to check if a string starts with the character: /
How can i accomplish this?
if(someString.indexOf('/') === 0) {
}
Characters of a string can be accessed through the subscript operator []
.
if (string[0] == '/') {
}
[0]
means the first character in the string as indexing is 0-based in JS. The above can also be done with regular expressions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With