Mobile Development- Using React Native - Lecture 8
Lecture Outcome:
At the end of the lecture, students will be able to know about
COLLECTIONS AND INTRO TO OOP (FOR REACT USERS)
run COLLECTION.js using VS Terminal (Practical)
# COLLECTIONS AND INTRO TO OOP (FOR REACT USERS)
# COLLECTIONS
-> SET ({1,3,4,2} {'a','b','c'} {"asf","saf","saf"})
-> [1,2,3,4,5], [1,3,4,3,2,1] ✅
-> [1,2,"name",3, true] ❌
SET === ARRAY
<!-- IN AN ARRAY DATA TYPE OF ELEMENTS SHOULD BE SAME -->
-> FreeHand
-> OBJECT
{'a',1,[1,3,4], "ahsfha", true }
<!-- FREE HAND IS AGNOSTIC FROM DATATYPE SIMILARITY -->
<!-- KEY PAIR SOLUTION -->
KEY : VALUE
{
x : 33,
y : "erozgar",
z : false
}
<!-- to create an OBJECT we have to use KEY PAIR structure -->
## ACCESS OF A VALUE OUT OF COLLECTIONS
myArray = [1,44,3,4,5]
const firstValue = myArray[1] ==> 44
# INDEXING ==> 0 = 1
<!-- COMPUTER STARTS COUNTING FROM 0 -->
<!-- trying to access an index which is not there is known as ArrayIndexOutOfBoundException -->COLLECTION.js
const arrayOne = [1,2,3,4,5]
const objectOne = {
1: "value",
2: 33,
3: [1,3,4],
4: true,
5: 'a'
}
// console.log(objectOne);
/// lets access the value in an ARRAY
const myArray = [33,22,11,44,55]
const firstValue = myArray[5]
console.log("firstValue", firstValue);

0 comments:
Post a Comment