Learn JavaScript VISUALLY

Learn JavaScript VISUALLY

English | 2015 | ISBN: 978-0993836701 | 133 Pages | EPUB | 10 MB


It’s a beautifully illustrated full-color JavaScript book that teaches the fundamentals through Metaphors, Analogies and Easy Step-by-Step Exercises.
WHO IS THIS JAVASCRIPT BOOK FOR?
If you answer YES to one or more of the following questions, this book is for you

  • I am a complete programming beginner
  • I know a little HTML and CSS
  • I tried to learn JavaScript before
  • I find programming books boring
  • I can’t focus long enough reading technical texts
  • I need to start really slow
  • I am a graphic and/or web designer
  • I have a book on JavaScript already
  • I am a parent who wants to spark an interest in programming in my kids

WHAT WILL I LEARN?

  • How to read and write JavaScript
  • The syntax of the language
  • The most important concepts
  • Programming terminology
  • Basics of the object oriented programming
  • To exercise regularly
+

Statements are commands that are executed one by one in the same order they are written, unless they are conditional statements. We have been using them for a while and they are separated by semicolon. So, even declaring and assigning a value to a variable is a statement on its own.

JavaScript statements can be grouped together into blocks by using curly brackets. You will often see this in functions, and control flow statements.

JavaScript does not have block scope. Instead, the scope is the same as the function or script that precedes it. This is very important because they do not introduce a scope, so if you use the same variable name thinking that they have different scopes, then your script will have bugs. While standalone block statements are allowed, they do not do what you would normally expect, and thus, you might just write your statements without them.

Here the block statement is interfering with the code outside, which is why the output is 2 instead of 1.

The Conditional statements are the ones that run only when their condition is met. More details on that will follow in a later chapter.

Another type of statement is the Exception Handling. They are used to work around with exceptions by using the throw statement andt then handling them with the try … catch statement.

When you throw an exception, you specify the expression containing the value to be thrown. Also, you can throw any expression, string, number, Boolean, and even functions!

When the web page is loaded, the browser automatically creates a Document Object Model of the page. As you learned before, every element of the page, excluding the document itself, is a child of another element. With the object model, you can use JavaScript to create dynamic HTML. JavaScript can change all the HTML elements, attributes, and CSS styles on the page. Furthermore, adding and removing elements and attributes, and even creating new HTML events on the page is possible.

With the usage of id in your HTML, you have access to specific nodes instead of just all the nodes of a certain type. That is why it is recommended to have different id names, to allow for more precise control.

To work with a particular id, you use the getElementById method,