Vous êtes sur la page 1sur 4

Unit 20

P3

Explain the fundamentals of a scripting language

Whats a scripting language?


Its a programming language that allows programs to be written in a
special run-time environment where tasks can be executed or interpreted
one at a time by a user. Scripting languages are interpreted instead of
being compiled because its easier to write the code in a scripting
language. It can be used to create graphical user interfaces that increases
the convenience of search engines, web based e-mail and e-commerce.
Each scripting language works differently but are mostly used to make a
website more interactive. It enhances the features of web pages by
making it more dynamic and it can provide extensions for the browser.
Nature of Language
The nature of the language is that it can be object orientated and eventdriven. Object oriented language implements objects and their related
procedures. The object knows what part of the website to interact with.
Object has functions known as methods and properties which holds
the data such as the main procedure of the project. Event driven language
is code that is split up into events. When the event is triggered, it
performs the function related to the triggered event.
Handling Events
An event handler is a function that contains program statements (code
that runs when an event occurs) that are completed in response to an
event, it processes actions such as mouse movements, mouse activity
which is on the GUI side (Graphical User Interface - operating system can
be controlled with a mouse by clicking on buttons etc. these are known as
events) on the input side, left clicking (mouse) to open and close files,
data streams e.g. music, movies.
Security Issues
There are various security issues when using web pages that include
scripting languages. For example with JavaScript your computer could be
hacked, then important data could be stolen or the hacker could corrupt
the files. To avoid such security threats, the users should regularly update
the web browsers with the latest security patches.
Including scripts inside HTML
Depending on the type of result wanted, the script can be positioned
anywhere inside a webpage. The browser is interpreting the HTML and its
being executed line by line. Scripts are to be between the two tags
<script> and </script> because only then the browser will know it is
interpreting a script and not HTML.

Dhanush Patel

Unit 20
P3

Scripting Language Constructs


Syntax:
-

Variables: Variables store data, and this data is sent to and


retrieved from the computers RAM (Random Access Memory). An
example of
code:

As you can see here a variable is


being used in the code. The variable
is bucky and the value of this
variable is 23. 23 is data stored in
the variable bucky.

The browser is displaying the value


of bucky which is 23.

Operators and Assignment operators: Operators are used to


calculate arithmetic links between the variable and the value. But
assignment operators assign values to variables. Example of
addition (+) operator being used:

As you can see here the code x +


y suggests what operator is being
used which is addition (+). The
variable x and y hold the numeric
values which is then calculated to
Dhanush Patel

Unit 20
P3

Loops:
For/In: Properties of an object are looped.

As you can see here the for/in


statement loops the properties of an
object to get the result Dhanush
Patel 18.

Decision making:
If/else: these are decision based statements. Results depend on if the
value is true or false. The If statement executes the code if the value is
true. The Else statement executes the code if the condition is false.
In this coding you can see the
resulted greeting depends on
the time of the day so for
example if the time is 9.30am
the value will be Good
Morning.

Functions:
Dhanush Patel

Unit 20
P3

Call/Parameter passing are two different types of functions. A call passing


allows you to gain access to the function and execute the code when you
need to. A parameter passing switches the value to or from a function in
its execution.

The function used here is showdate().Value is given to parameter passing


show date. The call passing used here is the click action which executes
the showdate() function.

Dhanush Patel

Vous aimerez peut-être aussi