Wednesday 3 February 2016

javascript - String contains another string




How can I check if a string contains another string instead of using "==" to compare the whole string?



Regards


Answer



You can use .indexOf():



if(str.indexOf(substr) > -1) {

}

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...