ちなみに、第二引数の走査開始インデックスは省略可能です。
window.onload = function () { if (!('contains' in String.prototype)) { String.prototype.contains = function (targetStr, searchStartIndex) { return -1 !== String.prototype.indexOf.call(this, targetStr, searchStartIndex); }; } }; function StringCheck() { var target = "One day in summer, a boy met a girl."; var result = target.contains("summer", 0); }
<input type="button" value="Contains test" onclick="StringCheck()" />
参考:String.contains