“String berisi substring JavaScript” Kode Jawaban

Periksa JavaScript Substring

const string = "javascript";
const substring = "script";

console.log(string.includes(substring));  //true
Batman

String berisi substring JavaScript

var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
	alert("Not again");
}
//use indexOf (it returns position of substring or -1 if not found)
Grepper

cara memeriksa apakah string berisi substring di javascript

const string = "foo";
const substring = "oo";

console.log(string.includes(substring)); // true
 Run code snippet
Angry Albatross

Bagaimana cara memeriksa apakah string berisi substring di JavaScript?


ECMAScript 6 introduced String.prototype.includes:

const string = "foo";
const substring = "oo";

console.log(string.includes(substring)); // true
shafeeque

JavaScript Periksa apakah string berisi substring teks

stringVariable.includes("Your Text");
Gifted Goldfinch

JavaScript string berisi

var string = "foo",
var substring = "oo";

console.log(string.includes(substring));
Average Ape

Jawaban yang mirip dengan “String berisi substring JavaScript”

Pertanyaan yang mirip dengan “String berisi substring JavaScript”

Lebih banyak jawaban terkait untuk “String berisi substring JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya