JavaScript में अ‍ैरे पार्ट 2: चाय और #JavaScript

Posted by

Array part 2 in Javascript

जावास्क्रिप्ट में एरे पार्ट २

जब हम बात करते हैं एरे की तो जावास्क्रिप्ट में यह एक बहुत ही महत्वपूर्ण डेटा स्ट्रक्चर है। यह हमें एक सरल तरीके से डेटा को स्टोर और मैनिपुलेट करने की सुविधा देता है।

एरे को डिफाइन करने के लिए हम ब्रैकेट [] का इस्तेमाल करते हैं। इसमें हम विभिन्न डेटा आइटम्स को कॉमा से अलग करते हैं। नीचे एक उदाहरण है:

    
        var fruits = ['आम', 'सेब', 'केला', 'अंगूर'];
    

यहाँ हमने एक फलों का एरे बनाया है जिसमें चार फलों के नाम हैं।

एरे में डेटा को एक्सेस करने के लिए हम इंडेक्स का इस्तेमाल करते हैं। इंडेक्स 0 से शुरू होता है और एक्सेस करने की क्रम का पता करने के लिए हम इंडेक्स नंबर का इस्तेमाल करते हैं।

उदाहरण के लिए:

    
        var fruits = ['आम', 'सेब', 'केला', 'अंगूर'];
        console.log(fruits[0]); // आम
        console.log(fruits[2]); // केला
    

इस तरह से हम जावास्क्रिप्ट में एरे का उपयोग करके डेटा को संग्रहित और उपयोग कर सकते हैं।

0 0 votes
Article Rating
49 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@HimanshuMeena-hi9nq
28 days ago

1

@NoorKhan-lr2tt
28 days ago

THANKS SIR FROM PAKISTAN🇵🇰

@AkbarHosen-yy4pf
28 days ago

please replay and check this one.. why typeof show its a object … insted of array .. check bellow

const first = "Rohim"

const newArray = Array.from(first);
(or const newArray = Array.of(first);)

console.log(newArray);

console.log(typeof newArray); // its shown object as a type .. but we convert it string to array ???

console.log(typeof first);

@theoldgamer3643
28 days ago

12:00

@udaypratap3977
28 days ago

sir if marvel_heros is const then how we are changing the value of const variable by using push method

@OsmanKhatana
28 days ago

can you please make type script series in Hindi?

@codewithsehran
28 days ago

The guy disserve more subscriber.

@igurutechs2583
28 days ago

I can relate him as a Web Developer trainer as when at 6:36 he's explaining about Concatenation he's getting unexpected output because sometimes we don't use some methods oftenly so we don't have confidence on it's output and get confused why is that happening, but to keep students motivated and don't let them think Sir ko itna bhi nhi ata we immediately try to show Oh we knew this will occur.. but then we take 1 min break for rechecking and then we debug and explain why that happened 😅😂

@user-wq2cj8wl4f
28 days ago

Bro all new hero me … Three dote ku diye hai isse jada bhi de sakte hai

@Vaibhavtiwri
28 days ago

10:30

@mahdymuzzammil1318
28 days ago

bhaia ji big fan

@swapPradhan
28 days ago

Heroes ❌❌
heros ✅✅

@binitgupta9371
28 days ago

//use of spread operator

let marvel_heros = ["Ironman", "Doctorstrange","Spiderman"]

let dc_heros = ["superman","batman","flash"]

let newarray = […marvel_heros,…dc_heros]

// console.log(newarray);

//use of flat method

let arr1 = [1,2,3,[4,5,6,7],[646,[4563,[5792]]]]

//inside flat() method depth is specified

let newarr1 = arr1.flat(4)

// console.log(newarr1);

// use of Array.from and Array.of

console.log(Array.from("Binit"));

let name1 = "Binit"

let name2 = "akash"

let name3 = "Ajay"

console.log(Array.of(name1,name3,name2,name1))

@KhanSirKiBate
28 days ago

sir ap previous output ko kaisey erase kar dte hai terminal se ???

@MH_BEAST_NET
28 days ago

OP

@ashishkandpalvlogs9702
28 days ago

push and concat both are different

@ashishkandpalvlogs9702
28 days ago

const marvel_heroes=["thor","Ironman","Spiderman"];

const dc_heroes=["Superman","flash","batman"];

// marvel_heroes.push(dc_heroes)

// console.log(marvel_heroes);

// console.log(marvel_heroes[3][1]);

marvel_heroes.concat(dc_heroes)

console.log(marvel_heroes)
ans wrong aa rha hain plz check code

@rutujapatil7435
28 days ago

Hi, sir, My name is Rutuja, and I enjoy watching your videos. I would like to ask for guidance on how to practice arrays. Could you provide me with some resources for solving questions related to arrays? I am preparing for an interview.

@Suman-ze8zz
28 days ago

Key Takeaways

1. push() method in array simply add the array as an new single entity in the existing array.
2. concat() method help us achieving a desisered output, like merging the two array, but the problems with concat are, It complicated to concat more then one array simultaneously and also It takes extra space and do the merging operation.
3. Despite push and concat we should use spread operator.
4. Intresting methods, isArray(), from() and of()

@AmanSharma-xy1qm
28 days ago

aap variable names bahut bde bde lete ho.