JavaScript dunyodagi eng mashhur dasturlash tili. JavaScript bu Internetning dasturlash tili



Download 249,3 Kb.
bet85/85
Sana01.02.2022
Hajmi249,3 Kb.
#421343
1   ...   77   78   79   80   81   82   83   84   85
Bog'liq
JS qo\'llanma

Original
Value


Converted
to Number


Converted
to String


Converted
to Boolean


Try it

false

0

"false"

false

Try it »

true

1

"true"

true

Try it »

0

0

"0"

false

Try it »

1

1

"1"

true

Try it »

"0"

0

"0"

true

Try it »

"000"

0

"000"

true

Try it »

"1"

1

"1"

true

Try it »

NaN

NaN

"NaN"

false

Try it »

Infinity

Infinity

"Infinity"

true

Try it »

-Infinity

-Infinity

"-Infinity"

true

Try it »

""

0

""

false

Try it »

"20"

20

"20"

true

Try it »

"twenty"

NaN

"twenty"

true

Try it »

[ ]

0

""

true

Try it »

[20]

20

"20"

true

Try it »

[10,20]

NaN

"10,20"

true

Try it »

["twenty"]

NaN

"twenty"

true

Try it »

["ten","twenty"]

NaN

"ten,twenty"

true

Try it »

function(){}

NaN

"function(){}"

true

Try it »

{ }

NaN

"[object Object]"

true

Try it »

null

0

"null"

false

Try it »

undefined

NaN

"undefined"

false

Try it »

Qo'shtirnoq ichidagi qiymatlar satr qiymatlarini bildiradi.
Qizil qiymatlar dasturchilar kutmagan qiymatlarni bildiradi (ba'zi).

JavaScript Bitwise operatsiyalari


❮ OldingiKeyingi ❯

JavaScript Bitwise operatorlari


Operator

Name

Description

&

AND

Sets each bit to 1 if both bits are 1

|

OR

Sets each bit to 1 if one of two bits is 1

^

XOR

Sets each bit to 1 if only one of two bits is 1

~

NOT

Inverts all the bits

<<

Zero fill left shift

Shifts left by pushing zeros in from the right and let the leftmost bits fall off

>>

Signed right shift

Shifts right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off

>>>

Zero fill right shift

Shifts right by pushing zeros in from the left, and let the rightmost bits fall off

Misollar


Operation

Result

Same as

Result

5 & 1

1

0101 & 0001

 0001

5 | 1

5

0101 | 0001

 0101

~ 5

10

 ~0101

 1010

5 << 1

10

0101 << 1

 1010

5 ^ 1

4

0101 ^ 0001

 0100

5 >> 1

2

0101 >> 1

 0010

5 >>> 1

2

0101 >>> 1

 0010

JavaScript 32 bitli Bitwise Operands dan foydalanadi


JavaScript raqamlarni 64 bit suzuvchi nuqta raqamlari sifatida saqlaydi, ammo barcha bitli operatsiyalar 32 bitli ikkilik raqamlarda bajariladi.
Bitta operatsiya bajarilishidan oldin JavaScript raqamlarni 32 bit imzolangan butun songa o'zgartiradi.
Bit bitli operatsiya bajarilgandan so'ng, natija yana 64 bitli JavaScript raqamlariga o'tkaziladi.
Yuqoridagi misollarda 4 bit imzosiz ikkilik raqamlardan foydalaniladi. Shuning uchun ~ 5 10 ga qaytadi.
JavaScript-da 32 bit imzolangan tamsayı ishlatilganligi sababli, u 10 ga qaytmaydi.
000000000000000000000000000000001 (5)
11111111111111111111111111111010 (~ 5 = -6)
Imzo qo'yilgan butun son minus belgisi sifatida eng chap bitdan foydalanadi.

Bitwise va


Agar bitli VA bit bitida bajarilsa, ikkala bit ham 1 bo'lsa, u 1 ni qaytaradi.
Bitta misol:

Ishlash

Natija

0 va 0

0

0 va 1

0

1 va 0

0

1 va 1

1

4 bitli misol:

Ishlash

Natija

1111 va 0000

0000

1111 va 0001

0001

1111 va 0010

0010

1111 va 0100

0100

Yagona yoki


Bit juftlik ustida bitli OR bajarilganda, bitlardan biri 1 bo'lsa, u 1 ga qaytadi:
Bitta misol:

Ishlash

Natija

0 | 0

0

0 | 1



1 | 0

1

1 | 1

1

4 bitli misol:

Ishlash

Natija

1111 | 0000

1111

1111 | 0001

1111

1111 | 0010

1111

1111 | 0100

1111

Bitorli XOR


Bit bitli XOR bit bitida bajarilganda, bitlar boshqacha bo'lsa, u 1 ga qaytadi:
Bitta misol:

Ishlash

Natija

0 ^ 0

0

0 ^ 1



1 ^ 0

1

1 ^ 1



4 bitli misol:

Ishlash

Natija

1111 ^ 0000

1111

1111 ^ 0001

1110

1111 ^ 0010

1101

1111 ^ 0100

1011

JavaScript Bitwise VA (&)


Bitwise AND har ikkala bit ham 1 bo'lgan taqdirda 1 ni qaytaradi:

O'nli

Ikkilik

5

0000000000000000000000000000000101

1

0000000000000000000000000000000001

5 va 1

0000000000000000000000000000000001 (1)

Misol


var x = 5 & 1;
O'zingiz sinab ko'ring »

JavaScript Bitwise YOKI (|)


Bit bitli OR, agar bitlardan biri 1 bo'lsa, 1 qaytaradi

O'nli

Ikkilik

5

0000000000000000000000000000000101

1

0000000000000000000000000000000001

5 | 1

000000000000000000000000000000001 (5)

Misol


var x = 5 | 1;
O'zingiz sinab ko'ring »

JavaScript Bitwise XOR (^)


Bitwise XOR, agar bitlar boshqacha bo'lsa, 1ni qaytaradi:

O'nli

Ikkilik

5

0000000000000000000000000000000101

1

0000000000000000000000000000000001

5 ^ 1

00000000000000000000000000000000100 (4)

Misol


var x = 5 ^ 1;
O'zingiz sinab ko'ring »

JavaScript Bitwise EMAS (~)


O'nli

Ikkilik

5

0000000000000000000000000000000101

~ 5

1111111111111111111111111111111010 (-6)

Misol


var x = ~5;
O'zingiz sinab ko'ring »

JavaScript (nol bilan to'ldirish) chapga chapga siljish (<<)


Bu chapga siljishni nol bilan to'ldirish. Bir yoki bir nechta nol bitlar o'ng tomondan itariladi va eng chap bitlar tushadi:

O'nli

Ikkilik

5

0000000000000000000000000000000101

5 << 1

0000000000000000000000000000001010 (10)

Misol


var x = 5 << 1;
O'zingiz sinab ko'ring »

JavaScript (Belgilarni saqlash) Bitwise o'ngga siljish (>>)


Bu to'g'ri siljishni saqlaydigan belgidir. Eng chap qismning nusxalari chap tomondan suriladi va eng o'ng bitlar tushadi:

O'nli

Ikkilik

-5

1111111111111111111111111111111011

-5 >> 1

1111111111111111111111111111111101 (-3)

Misol


var x = -5 >> 1;
O'zingiz sinab ko'ring »

JavaScript (Zero Fill) O'ngga o'tish (>>>)


Bu nolni to'ldirish o'ngga siljish. Bitta yoki bir nechta nol bit chapdan suriladi va eng o'ng bitlar tushadi:

O'nli

Ikkilik

5

0000000000000000000000000000000101

5 >>> 1

0000000000000000000000000000000010 (2)

Misol


var x = 5 >>> 1;
O'zingiz sinab ko'ring »

Ikkilik raqamlar


Bitta bitli ikkilik raqamlarni tushunish oson:

Ikkilik vakillik

O'nli qiymat

0000000000000000000000000000000001

1

000000000000000000000000000000000010

2018-04-02 121 2

0000000000000000000000000000000100

4

0000000000000000000000000000001000

8

00000000000000000000000000010000

16

00000000000000000000000000100100000

32

00000000000000000000000001000000

64

Yana bir nechta bitni o'rnatish ikkilik naqshni ko'rsatadi:

Ikkilik vakillik

O'nli qiymat

0000000000000000000000000000000101

5 (4 + 1)

0000000000000000000000000000001101

13 (8 + 4 + 1)

0000000000000000000000000010101010

45 (32 + 8 + 4 + 1)

JavaScript-ning ikkilik raqamlari ikkitaning qo'shimcha shaklida saqlanadi.
Bu shuni anglatadiki, manfiy son plyus 1 sonining bittasi YO'Q:

Ikkilik vakillik

O'nli qiymat

0000000000000000000000000000000101

5

1111111111111111111111111111111011

-5

0000000000000000000000000000000110

6

1111111111111111111111111111111010

-6

0000000000000000000000000010101000

40

11111111111111111111111111011000

-40

O'nlikni ikkilikka aylantirish

Misol


function dec2bin(dec){
return (dec >>> 0).toString(2);
}
O'zingiz sinab ko'ring »

Ikkilikni o'nlikka aylantirish

Misol


function bin2dec(bin){
return parseInt(bin, 2).toString(10);
}

JavaScript muntazam iboralari


❮ OldingiKeyingi ❯
Doimiy ifoda - bu izlash naqshini shakllantiruvchi belgilar ketma-ketligi.
Qidiruv naqshidan matnni qidirish va matnni almashtirish operatsiyalari uchun foydalanish mumkin.

Muntazam ifoda nima?


Doimiy ifoda - bu izlash naqshini shakllantiruvchi belgilar ketma-ketligi .
Matndagi ma'lumotlarni qidirishda ushbu qidiruv sxemasidan nimani qidirayotganingizni tasvirlash uchun foydalanishingiz mumkin.
Muntazam ibora bitta belgi yoki murakkabroq naqsh bo'lishi mumkin.
Matnni izlash va matnni almashtirish operatsiyalarining barcha turlarini bajarish uchun odatiy iboralardan foydalanish mumkin .

Sintaksis


/pattern/modifiers;

Misol


var patt = /w3schools/i;
Misol tushuntirildi:
/ w3schools / i doimiy iboradir.
w3schools - bu naqsh (qidirishda foydalanish uchun).
i modifikator (qidiruvni katta-kichikligiga qarab o'zgartiradi).

String usullaridan foydalanish


JavaScript-da odatiy iboralar ko'pincha ikkita satr usuli bilan ishlatiladi : search()va replace().
search()Usuli o'yinda qo'ng'iroq qilish uchun bir iborani ishlatadi, va o'yin o'rnini qaytaradi.
replace()Usuli namuna o'rnini bir tahrirlangan mag'lubiyatga qaytaradi.

String yordamida String search () dan foydalanish


search()Usul izlaydi, bir belgilangan qiymat va qaytib o'yinda pozitsiyasi uchun string:

Misol


Qatorda "W3schools" ni qidirish uchun satrdan foydalaning:
var str = "Visit W3Schools!";
var n = str.search("W3Schools");
O'zingiz sinab ko'ring »

String search () dan odatiy ifoda bilan foydalanish

Misol


"W3schools" qatorini kichik harflar bilan qidirish uchun oddiy iboradan foydalaning:
var str = "Visit W3Schools";
var n = str.search(/w3schools/i);
N natija quyidagicha bo'ladi:
6
O'zingiz sinab ko'ring »

String-ni almashtirish () -ni String bilan ishlatish


replace()Usuli bilan mag'lubiyatga boshqa qiymati bilan belgilangan qiymat o'rnini:
var str = "Visit Microsoft!";
var res = str.replace("Microsoft", "W3Schools");
O'zingiz sinab ko'ring »

String-dan foydalaning () muntazam ifodasi bilan

Misol


Bir qatorda Microsoft-ni W3Schools bilan almashtirish uchun harfga sezgir bo'lmagan doimiy ifodadan foydalaning:
var str = "Visit Microsoft!";
var res = str.replace(/microsoft/i, "W3Schools");
Natija quduq sohiblari bo'ladi:
Visit W3Schools!
O'zingiz sinab ko'ring »

E'tibor berganmisiz?


Muntazam ifoda argumentlari (satr argumentlari o'rniga) yuqoridagi usullarda ishlatilishi mumkin.
Muntazam iboralar sizning qidiruvingizni yanada kuchliroq qilishi mumkin (masalan, harflar sezgir emas).

Muntazam ifoda o'zgartirgichlari


Modifikatorlardan katta-kichik global qidiruvlarni amalga oshirish uchun foydalanish mumkin:

Modifier

Description

Try it

i

Perform case-insensitive matching

Try it »

g

Perform a global match (find all matches rather than stopping after the first match)

Try it »

m

Perform multiline matching

Try it »

Muntazam ifoda namunalari


Qavslar bir qator belgilarni topish uchun ishlatiladi:

Expression

Description

Try it

[abc]

Find any of the characters between the brackets

Try it »

[0-9]

Find any of the digits between the brackets

Try it »

(x|y)

Find any of the alternatives separated with |

Try it »

Metakarakterlar - bu alohida ma'noga ega bo'lgan belgilar:

Metacharacter

Description

Try it

\d

Find a digit

Try it »

\s

Find a whitespace character

Try it »

\b

Find a match at the beginning of a word like this: \bWORD, or at the end of a word like this: WORD\b

Try it »
Try it »

\uxxxx

Find the Unicode character specified by the hexadecimal number xxxx

Try it »

Quantifiers miqdorda aniqlash:

Quantifier

Description

Try it

n+

Matches any string that contains at least one n

Try it »

n*

Matches any string that contains zero or more occurrences of n

Try it »

n?

Matches any string that contains zero or one occurrences of n

Try it »

RegExp ob'ektidan foydalanish


JavaScript-da, RegExp ob'ekti oldindan belgilangan xususiyatlar va usullarga ega bo'lgan muntazam ekspression ob'ekti.

Test () dan foydalanish


test()Usul RegExp ifoda usuli hisoblanadi.
U naqshni izlaydi va natijaga qarab true yoki false qiymatini qaytaradi.
Quyidagi misol "e" belgisi uchun satrni izlaydi:

Misol


var patt = /e/;
patt.test("The best things in life are free!");
Satrda "e" bo'lganligi sababli yuqoridagi kodning chiqishi quyidagicha bo'ladi:
true
O'zingiz sinab ko'ring »
Avval doimiy o'zgaruvchini o'zgaruvchiga qo'yishingiz shart emas. Yuqoridagi ikkita satrni biriga qisqartirish mumkin:
/e/.test("The best things in life are free!");

Exec () dan foydalanish


exec()Usul RegExp ifoda usuli hisoblanadi.
U belgilangan naqshni izlaydi va topilgan matnni ob'ekt sifatida qaytaradi.
Agar mos keladigan narsa topilmasa, u bo'sh (null) ob'ektni qaytaradi .
Quyidagi misol "e" belgisi uchun satrni izlaydi:

1-misol


/e/.exec("The best things in life are free!");
O'zingiz sinab ko'ring »

To'liq RegExp ma'lumotnomasi


To'liq ma'lumot olish uchun to'liq JavaScript RegExp ma'lumotnomamizga o'ting .
Ma'lumotnomada barcha RegExp xususiyatlari va usullarining tavsiflari va misollari mavjud.
Download 249,3 Kb.

Do'stlaringiz bilan baham:
1   ...   77   78   79   80   81   82   83   84   85




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish