Arrays in JavaScript.!

Arrays in JavaScript – javaScriptda massivlar.!

Ta’rif: massivlar bir necha o’zgaruvchilarni o’z ichiga oluvchi maxsus o’zgaruvchi hisoblanadi.!

JavaScriptda massiv literalidan foydalangan xolda massiv hosil qilish eng qulay usul hisoblanadi.!
sinta…


This content originally appeared on DEV Community and was authored by samandar hodiev

Arrays in JavaScript - javaScriptda massivlar.!

Ta'rif: massivlar bir necha o'zgaruvchilarni o'z ichiga oluvchi maxsus o'zgaruvchi hisoblanadi.!

JavaScriptda massiv literalidan foydalangan xolda massiv hosil qilish eng qulay usul hisoblanadi.!
sintaksis: const array_name_ = [item1,item2,item3,...]

Misol uchun: Biz mevalar ro'yxatini bor va uni bitta o'zgaruvchida saqlash quyidagi misoldagidek bo'ladi.

const fruit1_ = 'lemon';
const fruit2_ = 'banana';
const fruit3_ = 'nut';

Ammo biza mevalar soni ro'yxatda sanoqlik emas juda ko'p bo'sachi.? Ro'yxatdagi mevalardan aynan birini tanlab olmoqchi bo'lsakchi.? ETC...

Albatta bu xolda yechim massiv(Array).!

const fruits_ = ['lemon','nut','banana','apelsin','mango','peach']

Biz massiv hosil qilibbo'lgach elementlarni taqdim etishimizham mumkin, va misolda ko'rishimiz mumkinki.!
typef funcsiyasidan foydalanib massivimiz qaysi data tipga tegishli ekanini aniqlaganimizda object tipiga mansub ekanini ko'rishimiz mumkin, bir so'z bilan aytganda massivlar obyektlarning maxsus turi.!

const colors = [];
colors[0]='white';
colors[1]='black';
colors[2]='yellow';
colors[3]='blue';
colors[4]='red';

console.log(colors);
//natija - ['white', 'black', 'yellow', 'blue', 'red']


console.log(typeof colors)
natija - object

new Array konstruktoridan foydalanibham quyidagi usulda massiv hosil qilish mumkin, ammo doim literal usulda array hosil qilish tavsiya etiladi.!

const new_array = new Array('length','toString','indexOf','includes');
console.log(new_array);
//natija - ['length', 'toString', 'indexOf', 'includes']

JavaScript da massivlar raqamlangan indekslardan foydalanadi.


This content originally appeared on DEV Community and was authored by samandar hodiev


Print Share Comment Cite Upload Translate Updates
APA

samandar hodiev | Sciencx (2024-06-29T16:11:27+00:00) Arrays in JavaScript.!. Retrieved from https://www.scien.cx/2024/06/29/arrays-in-javascript/

MLA
" » Arrays in JavaScript.!." samandar hodiev | Sciencx - Saturday June 29, 2024, https://www.scien.cx/2024/06/29/arrays-in-javascript/
HARVARD
samandar hodiev | Sciencx Saturday June 29, 2024 » Arrays in JavaScript.!., viewed ,<https://www.scien.cx/2024/06/29/arrays-in-javascript/>
VANCOUVER
samandar hodiev | Sciencx - » Arrays in JavaScript.!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/29/arrays-in-javascript/
CHICAGO
" » Arrays in JavaScript.!." samandar hodiev | Sciencx - Accessed . https://www.scien.cx/2024/06/29/arrays-in-javascript/
IEEE
" » Arrays in JavaScript.!." samandar hodiev | Sciencx [Online]. Available: https://www.scien.cx/2024/06/29/arrays-in-javascript/. [Accessed: ]
rf:citation
» Arrays in JavaScript.! | samandar hodiev | Sciencx | https://www.scien.cx/2024/06/29/arrays-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.