जावास्क्रिप्ट में एरे पार्ट २
जब हम बात करते हैं एरे की तो जावास्क्रिप्ट में यह एक बहुत ही महत्वपूर्ण डेटा स्ट्रक्चर है। यह हमें एक सरल तरीके से डेटा को स्टोर और मैनिपुलेट करने की सुविधा देता है।
एरे को डिफाइन करने के लिए हम ब्रैकेट [] का इस्तेमाल करते हैं। इसमें हम विभिन्न डेटा आइटम्स को कॉमा से अलग करते हैं। नीचे एक उदाहरण है:
var fruits = ['आम', 'सेब', 'केला', 'अंगूर'];
यहाँ हमने एक फलों का एरे बनाया है जिसमें चार फलों के नाम हैं।
एरे में डेटा को एक्सेस करने के लिए हम इंडेक्स का इस्तेमाल करते हैं। इंडेक्स 0 से शुरू होता है और एक्सेस करने की क्रम का पता करने के लिए हम इंडेक्स नंबर का इस्तेमाल करते हैं।
उदाहरण के लिए:
var fruits = ['आम', 'सेब', 'केला', 'अंगूर'];
console.log(fruits[0]); // आम
console.log(fruits[2]); // केला
इस तरह से हम जावास्क्रिप्ट में एरे का उपयोग करके डेटा को संग्रहित और उपयोग कर सकते हैं।
1
THANKS SIR FROM PAKISTAN🇵🇰
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);
12:00
sir if marvel_heros is const then how we are changing the value of const variable by using push method
can you please make type script series in Hindi?
The guy disserve more subscriber.
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 😅😂
Bro all new hero me … Three dote ku diye hai isse jada bhi de sakte hai
10:30
bhaia ji big fan
Heroes ❌❌
heros ✅✅
//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))
sir ap previous output ko kaisey erase kar dte hai terminal se ???
OP
push and concat both are different
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
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.
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()
aap variable names bahut bde bde lete ho.