“JavaScript memulai beberapa nilai” Kode Jawaban

Mulai dengan periksa fase multipl

if (newStr4.startsWith("Mon") || newStr4.startsWith("Tues") || ...)

Or you could use regular expression:

if (newStr4.matches("(Mon|Tues|Wed|Thurs|Fri).*"))
Cute Caterpillar

JavaScript memulai beberapa nilai

hi hi I tried this in Groovvy
["Mon","Tues","Wed","Thurs"].any { newStr.startsWith(it) }

hope it helps
Powerful Peccary

JavaScript Multiple Startswith

//There is NO possibility to passing an Array
//like startsWith(["Mon" | "Tues"])
if (newStr4.startsWith("Mon") || newStr4.startsWith("Tues") || ...)

//although you can use regular expression,
//but performance are lower than the solution above
 if (newStr4.matches("(Mon|Tues|Wed|Thurs|Fri).*"))
POG

Jawaban yang mirip dengan “JavaScript memulai beberapa nilai”

Pertanyaan yang mirip dengan “JavaScript memulai beberapa nilai”

Lebih banyak jawaban terkait untuk “JavaScript memulai beberapa nilai” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya