reading-notes

https://r-alhayek.github.io/reading-notes/

View project on GitHub

JavaScript

Introduction:

JavaScript can be used in browsers to make websites more interactive, interesting, and user-friendly. It can also change the content of an HTML page while it is loaded in the browser which rely on the ability to:

  • Access the content of the page.
  • Modify the content of the page.
  • Program rules or instructions the browser can follow.
  • React to events triggered by the user or browser.

EXPRESSIONS

An expression evaluates into (results in) a single value. Broadly speaking there are two types of expressions:

  1. EXPRESSIONS THAT JUST ASSIGN A VALUE TO A VARIABLE. In order for a variable to be useful, it needs to be given a value. As you have seen, this is done using the assignment operator (the equals sign).

  2. EXPRESSIONS THAT USE TWO OR MORE VALUES TO RETURN A SINGLE VALUE. You can perform operations on any number of individual values (see next page) to determine a single value.

FUNCTIONS

Functions let you group a series of statements together to perform a specific task. If different parts of a script repeat the same task, you can reuse the function (rather than repeating the same set of statements). Some Functions need to be provided with information in order to achieve a given task. Pieces of information passed to a function are known as Parameters. The response to a written function is known as a return value.

  • Declaring a function:To creat a function, you give it a name then write the statements needed to aceive its task inside the curly braces.

  • Calling a function: You can excute all of the statements between the function’s curly braces with just one line of code. To run the code in the function, You use the function name between parantheses().
    • Sometimes a function needs a specific information to perform its task. In such cases, when you deaclare the function, you give it Parameters. Inside the function, the parameters acts like variables.
  • Getting a single value out of a function: Some functions return information to the function that called them. For example, when they perform a calculation, they return the result.