“Periksa JavaScript Substring” Kode Jawaban

Periksa JavaScript Substring

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

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

JavaScript string berisi

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

console.log(string.includes(substring));
Cautious Crane

JavaScript Periksa apakah string berisi substring

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

. termasuk (string


var str = "Hello world, welcome to the universe.";
var n = str.includes("world");
 
Black Necked Stork

String.Contains JavaScript

var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
	alert("Not again");
}
Misty Manatee

JavaScript Periksa apakah string berisi substring teks

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

Jawaban yang mirip dengan “Periksa JavaScript Substring”

Pertanyaan yang mirip dengan “Periksa JavaScript Substring”

Lebih banyak jawaban terkait untuk “Periksa JavaScript Substring” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya