JS Fundamentals

An analogy to describe JavaScript and its relationship to HTML and CSS.

 

Javascript is like the wizzard that does all the magic behind the scenes, HTML is the blueprint that contains all the building blocks for the thing you want to create, and CSS is your annoying artist friend that beautifys the blueprint.

 

A description of Control Flow and Loops

 

You can relate the concept of control flow in coding with real life events, for example; when you are cooking you follow a step process that flows from start to finish.

  1. Get the ingredients
  2. Prep ingredients for cooking
  3. Cook ingredients
  4. Serve the meal
 

Loops in coding let us programmers repeat an instruction until a certain condition is met. An example of a loop in a real world example could be when serving dinner to your family of 4, you repeat the instruction of plating, and serving the meal until your condition of serving all 4 family members is met, then you stop the serving process.

 

The DOM and how you might interact with it

 

The DOM (Document Object Model) is the glue that glues HTML, CSS, and JavaScript together. The DOM can be visually represented like a family tree, with the .document being the grabdfather, and it’s children being HTML, then it’s children being the head and body, etc. These things that make up the DOM are called nodes. Nodes represent the children from my previous comparrison. You would first interact with the DOM by first clicking the ‘inspect’ button on a web page, then using certain lines of code like ‘document.querySelector()’ you can select specific elements in the DOM that you want to configure. Thats just the gateway into the world of the DOM, as there is so much more you can do with it.

 

The difference between Arrays and Objects in simple terms

 

Arrays: Think of an array like a numbered list where you put items in order. To get something, you ask for it by its number in the list.

Objects: An object is like a collection of labeled boxes on a shelf. Each box has a name, and you ask for something by its name.

 

An explination on what Functions are and why they are helpful.

Functions are like sets of insctructions that you can use over and over again when you need them, like a recipe. You just need to write them once, then when you need them you can use them. They make writing JavaScript way more efficient! For example, you could use the Loop instruction I discussed before and make that a function.

 
Back to Index