3rd Week of #100DaysOfCode with JavaScript. What did I Learn so far?

Nick Hollins
4 min readMay 25, 2020

Topic I learned this week: JavaScript Arrays

JavaScript arrays is a important topic that I learned this week. Arrays are definitely another one of those concepts that you will see over and over again in programming. A JavaScript array is basically something you would use when you want to store a ordered collection of information. I didn’t learn every aspect of an array such as a multidimensional array, internals, etc. Lets take a look at how you would declare an array.

Declaring an array

In this code snippet I am declaring an array that has a list of fruits. I could have also declared an array using the syntax: let fruits = new Array(); .

The most common way to declare an array is the way I did it in the code snippet. We can access each element in the array. The elements in the array are numbered starting with zero. Lets take a look at how this work.

Accessing each element in the array

In this code snippet I am accessing each element inside of the array. It is always important to know that indexing starts at 0. You can also mutate elements in the array as well. I will give an example of what I mean by that.

Mutating elements in the array

In this example, I changed the first element in the array (apple) to banana instead. This is called mutating elements. We can also add elements to the array using the same concept.

These are the extreme basics of a JavaScript array but I have the overall concept of what they are and what they do.

Topic I learned This Week: JavaScript Objects

This is a concept that I am still learning but I will talk about what I do know about it so far. A JavaScript Object penetrates almost every aspect of the language according to JavaScript.info. Objects are used to store keyed collection of various data. An Object can have a optional list of properties. These properties has a key: value pair. The key is the is the property name and the value could be anything. Lets take a look at how we would declare a object.

Declaring a Object Literal

In this example I declared a object named ‘nick’. Inside of the object I have different properties to describe the object such as first name, last name, birth year, and siblings. Notice how some of these properties have different data types. It do not have to be one type of data type inside of the object. There is another way to declare an object. The way that I declared the object is called an Object Literal. I could've also declared it like this: let nick = new Object(); This is called the object constructor syntax.

Usually it is common to see the object literal syntax more. In the example above , firstName would be the ‘Key’ and Nick would be the ‘value’ to that key. You can access elements in the object using the dot notation. So in the example above, I used console.log(nick.firstName); This will print my first name on the browser console. Unfortunately this is pretty much all that I have learned about objects this week but I am definitely excited to learn more about objects and how they work.

Summary

I think that I am moving at a decent pace for learning JavaScript. I like the fact that I am struggling to figure out how some of these concepts work because that just mean I am learning! I look forward to learning more things this week.

References

JavaScript.info

Jonas Udemy Course

Follow Me On Social Media

Instagram

Facebook

LinkedIn

--

--

Nick Hollins

Developer. Writer. Creator. Always learning. Feel free to email me: hollinsaquile@gmail.com