Java Script uchun qo’llanma Samarqand Davlat universiteti talabasi Ibrohimov Ismoiljon tomonidan tayyorlandi. Kamchiliklar uchun uzr…!


JavaScript Strings The matchAll() Method


Download 227.69 Kb.
bet11/22
Sana04.04.2023
Hajmi227.69 Kb.
#1325028
1   ...   7   8   9   10   11   12   13   14   ...   22
Bog'liq
JS ( Ibrohimov )

JavaScript Strings

The matchAll() Method


ES2020 intoduced the string method matchAll().
Cats,Cats


includes() Agar satrda belgilangan qiymat bo'lsa, usul true ni qaytaradi .
Aks holda false qaytib keladi.

JavaScript Strings


The includes() Method


Check if a string includes "world":

NATIJA :: :


JavaScript Strings

The includes() Method


Check if a string includes "world":
true

Satrda "world" mavjudligini tekshiring. 12-pozitsiyadan boshlang:


let text = "Hello world, welcome to the universe.";


text.includes("world", 12);
// false

Agar satr belgilangan qiymatdan boshlansa, usul startsWith() true qaytariladi . Aks holda false:


The startsWith() method is not supported in Internet Explorer.



NATIJA :: :


true

Bu yerda berilgan satr Hello so’zidan boshlangani uchun true qiymati qaytardi.


Agar text.startsWith(world) bo’lganda false qaytarar edi…

Qidiruv uchun boshlang'ich pozitsiyasi belgilanishi mumkin:


let text = "Hello world, welcome to the universe.";


text.startsWith("world", 6) ;
// true
world so’zi 6-indexdan boshlangani uchun true qiymat qaytariladi.

Agar satr belgilangan qiymat bilan tugasa, endsWith() true qaytariladi .


Aks holda u false:
let text = "John Doe";
text.endsWith("Doe"); // true

Satrning 11 ta birinchi belgisi "world" bilan tugashini tekshiring:


let text = "Hello world, welcome to the universe.";
text.endsWith("world", 11); // true

Bu yerda world so’zi 11-index bilan tugagani uchun true qiymat qaytaradi.




Download 227.69 Kb.

Do'stlaringiz bilan baham:
1   ...   7   8   9   10   11   12   13   14   ...   22




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling