Javascript Basics:


How does Javascript compare to HTML and CSS?

You have the HTML markup language for content and structure. What is your headline, how many divisions are in your page, how many paragraphs do you have, what are the contents of those paragraphs.

Then the CSS, the style sheet language, for presentation. What font does the headline use, what's the background color of the page, what is the width of the div that the paragraphs are in.

JavaScript is the programming language for your behavior and interactivity.

What happens when you move the mouse over a menu, what happens when you type the wrong value in a form field, how long does a photo slideshow take to move from one image to the next, that is JavaScript.

Explain control flow and loops using an example process from everyday life:

Control flow is the order that the program would be executed

Loops are powerful constructs that you can use to reiterate a series of JavaScript statements over and over again. JavaScript supports a number of loops you can choose from, including the for loop and for-in loops, the while loop, and the do-while loop.

A real-life example would be if I want to buy a new shirt:

The first thing I would do is to try the shirt on: shirt(try it on). Then if (you like it?) {Buy it!}. Else if (do not like it?) {try another one!}. else {walk off the shop};.

Explain the difference between accessing data from arrays and object literals:

Arrays and Objects literals are both data holders.

To access the array: arrayName[i]

How to access the object: anObject.anotherObject

Explain what functions are and why they are useful:

A function is a named group of JavaScript statements that you can declare once, near the top of your script, and call over and over again. Adding a reusable function to your script instead of adding several slightly different versions of the same code, cuts down on the amount of typing that you need to do, as well as the number of potential bugs in your script.