Arrays and Objects

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 152:- Arrays and Objects

Arrays and objects are two fundamental data types in JavaScript used to store and manipulate collections of values.

An array is an ordered collection of values, where each value is identified by an index, starting from zero. We can use arrays to store a list of values of any data type, including strings, numbers, objects, and even other arrays. Arrays are represented using square brackets [].

For example:

arduinoCopy code

const fruits = ['apple', 'banana', 'orange']; const numbers = [1, 2, 3, 4, 5]; const mixed = ['apple', 1, { name: 'John', age: 30 }, true];

An object, on the other hand, is an unordered collection of key-value pairs, where each key is a unique string that identifies a value. We can use objects to store information about a single entity, such as a person or a product. Objects are represented using curly braces {}.

For example:

cssCopy code

const person = {  name: 'John',  age: 30,  hobbies: ['reading', 'running'],  address: {    street: '123 Main St',    city: 'New York',    state: 'NY'  } };

We can access the values stored in arrays and objects using dot notation or square bracket notation. In dot notation, we use the . operator to access the value of a property or an element of an array. In square bracket notation, we use the [] operator and provide the index or key as a string.

For example:

cssCopy code

const fruits = ['apple', 'banana', 'orange']; const person = {  name: 'John',  age: 30,  address: {    street: '123 Main St',    city: 'New York',    state: 'NY'  } }; console.log(fruits[0]); // Output: 'apple' console.log(person.name); // Output: 'John' console.log(person.address['city']); // Output: 'New York'

Arrays and objects are powerful data types that can be combined to create complex data structures and algorithms.

17. Objects and Timing Events

Comments: 2

profile
@niteshguptav63
17-Nov-2024, 01:39 PM

I am not able to access videos from second class and further. I have already completed first class

profile
@niteshguptav63
16-Nov-2024, 10:56 AM

When will I get my course?

profile
@admin79
17-Nov-2024, 01:29 PM

Now, Your query was resolved.

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?