Week 6- We’ll Ace it together.

Alwaz Qazi
3 min readMar 20, 2021

--

Photo by Shane Rounce on Unsplash

Ahhh what a busy week.

Make sure to read till the end as I’m writing this at 3:00 a.m . If not then make sure to read the last paragraph. (ツ)

This week we dive deeper into Java Script by learning.

  • Functions
  • DOM Manipulation
  • event listeners

Functions

Functions, a very important concept in any language because they are used to make your code reusable and readable.

Syntax: function can be declared by using the keyword ‘function’ proceeding function name and round brackets ().

function functionName(){
//function body
}

Example: In the example below a function is declared by the name “names” having some attributes in it, and it is called below by it’s name.

A function can have arguments as well as shown below.

Arguments are of two types

  • Pass by value
  • Pass by reference

Pass by Value:

Lets take a look at the example below. A variable called username is declared and assigned a value john. Then another variable user2 is declared and assigned the value of username i.e John. Now, the value of username is changed to ‘smith’ but when user2 is printed you can see it’ll still print John and not smith because username and user2 dont have any link between them just the value was passed. That’s what pass by value is.

Pass by Reference:

In this article I figured out it’s not possible in java Script. You guys can check and correct me if I’m wrong.

Document Object Model (DOM)

I know it sounds scary but it’s fun. DOM in javascript is used to access and manipulate data of html by using Java Script. You need to link javascript file into html file by using <script src =”file.js”> tag. Make sure to add this tag at the bottom within the body tag so that all of your html elements are loaded first otherwise java Script wont be able to recognize them.

Now, create a separate .js file and access your html elements from there and apply functionality to them for example what will happen if you click on a button etc. That’s what you can do with DOM.

Honestly, I had no idea what DOM was but thanks to my Tribe because we already practiced it that’s why I didn’t freak out.

Next we moved to Object Oriented concepts and then we moved to CRUD Operations 😐

CRUD Create, Read, Update and Delete and that’s where things started getting complicated actually. And I’m not alone in this many fellows freaked out after today’s session, but we’ll do this together, we’ll help each other and learn. That’s the beauty of community. I’m having trouble with it because I’m having my exams and cant focus here I know I can do that, I understand what’s going on in CRUD I just need practice that i’ll start once I’m done with my exams. because right now I’m brain dead actually.

That’s all folks. Thanks for reading.

Peace ✌️

--

--

Alwaz Qazi
Alwaz Qazi

No responses yet