Answers:
ECMAScript 6 හඳුන්වා දී ඇත String.prototype.includes:
const string = "foo";
const substring = "oo";
console.log(string.includes(substring));includes ඉන්ටර්නෙට් එක්ස්ප්ලෝරර් සහාය නැත. ECMAScript 5 හෝ ඊට වැඩි පරිසරයක, String.prototype.indexOfඋපස්ථරයක් සොයාගත නොහැකි වූ විට -1 නැවත ලබා දෙන භාවිතය :
var string = "foo";
var substring = "oo";
console.log(string.indexOf(substring) !== -1);string.toUpperCase().includes(substring.toUpperCase())
                    /regexpattern/i.test(str)-> i කොඩි නඩුවේ කරු අසංවේදී සඳහා කි්රයා
                    ඒ නිසා එය String.prototype.includesES6 දී :
"potato".includes("to");
> trueඉන්ටර්නෙට් එක්ස්ප්ලෝරර් හෝ වෙනත් පැරණි බ්රව්සර් වල මෙය ක්රියාත්මක නොවන බව සලකන්න . පැරණි බ්රව්සර්වල එය ක්රියාත්මක කිරීම සඳහා, ඔබට බාබෙල් වැනි ප්රවාහකයෙකු, එස් 6-ෂිම් වැනි ෂිම් පුස්තකාලයක් හෝ එම්ඩීඑන් වෙතින් මෙම පොලිෆිල් භාවිතා කිරීමට අවශ්ය විය හැකිය :
if (!String.prototype.includes) {
  String.prototype.includes = function(search, start) {
    'use strict';
    if (typeof start !== 'number') {
      start = 0;
    }
    if (start + search.length > this.length) {
      return false;
    } else {
      return this.indexOf(search, start) !== -1;
    }
  };
}"potato".includes("to");එය කර බාබෙල් හරහා ධාවනය කරන්න .
                    "boot".includes("T")isfalse
                    තවත් විකල්පයක් වන්නේ KMP (Knuth-Morris-Pratt) ය.
එය length- සඳහා KMP ඇල්ගොරිතමය සෙවුම් මීටර් substring වූ length- දී n string නරකම දී සාමාන්ය ( n + මීටර් ) කාලය, ඕ නරකම සාපේක්ෂව ( n ⋅ මීටර් වූ බොළඳ ඇල්ගොරිතමය සඳහා) එසේ KMP මැයි භාවිතා නරකම කාල සංකීර්ණත්වය ගැන ඔබ සැලකිලිමත් වන්නේ නම් සාධාරණ වන්න.
Https://www.nayuki.io/res/knuth-morris-pratt-string-matching/kmp-string-matcher.js වෙතින් ලබාගත් ව්යාපෘති නායුකි විසින් ජාවාස්ක්රිප්ට් ක්රියාත්මක කිරීම මෙන්න :
// Searches for the given pattern string in the given text string using the Knuth-Morris-Pratt string matching algorithm.
// If the pattern is found, this returns the index of the start of the earliest match in 'text'. Otherwise -1 is returned.function kmpSearch(pattern, text) {
  if (pattern.length == 0)
    return 0; // Immediate match
  // Compute longest suffix-prefix table
  var lsp = [0]; // Base case
  for (var i = 1; i < pattern.length; i++) {
    var j = lsp[i - 1]; // Start by assuming we're extending the previous LSP
    while (j > 0 && pattern.charAt(i) != pattern.charAt(j))
      j = lsp[j - 1];
    if (pattern.charAt(i) == pattern.charAt(j))
      j++;
    lsp.push(j);
  }
  // Walk through text string
  var j = 0; // Number of chars matched in pattern
  for (var i = 0; i < text.length; i++) {
    while (j > 0 && text.charAt(i) != pattern.charAt(j))
      j = lsp[j - 1]; // Fall back in the pattern
    if (text.charAt(i) == pattern.charAt(j)) {
      j++; // Next char matched, increment position
      if (j == pattern.length)
        return i - (j - 1);
    }
  }
  return -1; // Not found
}
console.log(kmpSearch('ays', 'haystack') != -1) // true
console.log(kmpSearch('asdf', 'haystack') != -1) // false
indexOf()ඒක තමයි ...