In this lesson we will understand what is a JavaScript object, how its created and used in an example project.
PROJECT FILES
https://drive.google.com/open?id=16P7bMZ43Nr64zj0U_7obeCE0uCo-y1eE
We are using an example project which is a resume website that includes portfolio. This portfolio does not contain any images, title or description INSIDE the HTML. Rather it is in a separate data file. What we have to do it fetch data from this file based on what portfolio DIV is clicked. The information of that portfolio will be displayed in a modal.
This modal is created only once and displays the data according to the clicks. We will create different objects in our reference file where each object will represent one set of actions (or properties). For example, we will reference the complete modal and its buttons, links, icons, image inside an object and use it smartly to write our logic. If we will not follow this approach, we will fall into writing too much codes with too little impact.
So what is object? Object is a key value pair, where keys have a user-defined name that can be called easily to access the value. The object is created in a way similar to a variable, and defined in a way similar to an array (with slightly different brackets and commas).
Comments
Post a Comment