Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 3.71 KB

File metadata and controls

62 lines (47 loc) · 3.71 KB

this is read06

Java Script

image

How JavaScript Makes Web Pages More Interactive :

  1. Access the content
  2. modify content
  3. program rules
  4. React to event

HTML && CSS :

HTMLCSS HTML element : are added to the contentof page to describe its structure.an element consist of the opening and closing tags plus its content.

CSS rules : uses ti indecate how the contents of one or more element should be displayed in the bowser. Each rule has a selector and a declaretion block.

#Descining A Script: the goal of script it can work out the individual taskes nedeed to achieve it. Each individual task may be broken down into a sequence of steps.

EXPRESSIONS:

there are two types of expressions: 1. EXPRESSIONS THAT JUST ASSIGN A VALUE TO A VARIABLE:it needs to begiven 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.

OPERATORS :

they allow programmers tocreate a single value from one or more values. there are types of operators: 1. ASSIGNMENT OPERATORS : Assign a value to a variable 2. ARITHMETIC OPERATORS :Perform basic math 3. STRING OPERATORS : Combine two strings. 4. COMPARISON OPERATORS : Compare two values and return true or false. 5. LOGICAL OPERATORS :Combine expressions and return true or false.

Declearing A Function :

To creat a function you give it a name and then write the statments need to achieve its taske inside the curly braces. 1. you declear a function using the function keyword. 2. give a function name called identifier followed by parentheses. 3. the statments that perform the task sit in a code block. the function store the code required to perform a specific task and that script can ask the function to perform that task whenever you needed. If different parts of a script need to perform the same task; you dont need to repeat the same statments multiple times ; you use the a function to do it and reuse the same code.

Calling A Function :

first decleared the function then you can execute all the statments between its curly braces with just one line of code; and this known call function.

  • TO run the code in function, you use the function name followed by parentheses.You can call the same function as many times as you want within the same JavaScript file.
    1. the function can store the instructions for a specific task.
    2. when you need the script to perform that task you call the function.
    3. the function execute the code in that code block .
    4. when it has finished, the code continues to run from the point where it was initially called.

Declearing function that need information :

sometimes a function needs specific information to perform its task.when you declear the function you give it parameters.this parameters insude the function will act as a variable.

calling function that need information :

when call a function that has parameters you specify the value it should use in the parentheses that follow its name.that value called arguments and it can provied as value or as variable.

  1. arguments as value : getArea(3,2)
  2. arguments as variable : dont need to specify actual values when calling function; you can use variable in their place.

gitting a single value out of a function:

some function return information to the code that called them such as when you perform a calculation they return the result.