Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 1.71 KB

read07.md

File metadata and controls

40 lines (32 loc) · 1.71 KB

Javascript

How JavaScript makes pages more attractive:

  • Access content
  • Modify content
  • Add program rules
  • React to events

Examples of using Javascript:

  • Slideshows
  • Forms
  • Reload part of the page
  • Filtering data

What is a script:

A script is a series of instructions that a computer can follow to achieve a goal.

How to write a script:

To write a script, you need to first state your goal and then list the tasks that need to be completed in order to achieve it.

To approach writing a script, break down your goal into a series of tasks and then work out each step needed to complete that task (a flowchart can help).

EXPRESSIONS

An expression evaluates into (results in) a single value. Broadly speaking

there are two types of expressions :

  • EXPRESSIONS THAT JUST ASSIGN A VALUE TO A VARIABLE *EXPRESSIONS THAT USE TWO OR MORE VALUES TO RETURN A SINGLE-VALUE.

OPERATORS

Expressions rely on things called operators; they allow programmers to create a single value from one or more values.

  • ASSIGNMENT OPERATORS (=)
  • COMPARISON OPERATORS (< , >, ==)
  • ARITHMETIC OPERATORS(- , * , / , +)
  • LOGICAL OPERATORS(and, or, nor)
  • STRING OPERATORS ( + )

FUNCTION

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).

Declering a function :

To create a function, you give it a name and then write the statements needed ta achieve its task inside the curly brace and the function can by calling any time you want and you can declare a function that takes information and you can get a value back from at by using a return.