read 06
Java Script Introdution
JavaScript allows you to make web pages more interactive byaccessing and modifying the content and markup used ina web page while it is being viewed in the browser
A script is a series of instructions that a computer can follow to achieve a goal. Often scripts will need to perform different tasks in different situations. You can use flowcharts to work out how the tasks fit together. **Each time the script runs, it might only use a subset of all the instructions. **
- Computers approach tasks in a different way than humans, so your instructions must let the computer solve the task prggrammatically.
Being able to change the content of an HTML page while it is loaded in the browser is very powerful.
- 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 : var color = ‘beige’;
- 2 EXPRESSIONS THAT USE TWO OR MORE VALUES TO RETURN A SINGLE VALUE var area = 3 * 2;
OPERATORS
Expressions rely on things called operators; they allow programmers to create a single value from one or more values.

ARITHMETIC OPERATORS
JavaScript contains mathematical
operators, which you can use with numbers. You may remember some from math class.

STRING OPERATOR
There is just one string operator: the+ symbol. It is used to join the strings on either side of it.

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).
- Declaring a function To create a function you give it a name and then write the statement needed to achieve its task inside the curly braces(function declaration).

-
declaring functions with arguments:

-
Calling a function Having declared the function ,you can then execute all of the statement between its curly braces with just one line of code.

- VARIABLE SCOPE The location where you declare a variable will affect where it can be used within your code. If you declare it within a function, it can only be used within that function. This is known as the variable’s scope.
- HOW MEMORY & VARIABLES WORK Global variables use more memory. The browser has to remember them for as long as the web page using them is loaded. Local variables are only remembered during the period of time that a function is being executed.