Introduction To JavaScript Notes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Introduction to JavaScript 2023

Introduction to Java Scripting Language (JavaScript)

JavaScript is programming code inserted into an HTML page. It is used to make web pages more
dynamic as well as interactive.

JavaScript is different from HTML because JavaScript is used to create more dynamic web pages
while HTML is a markup language that is used to create static content on the web page.

JavaScript code is inserted in a HTML file by using the <script> tag. No special program is
required in order to write code in JavaScript as it is an interpreted language. You can use any text
editor such as Notepad in order to write JavaScript code

<script> : opening script tag: defines the JavaScript code

java script code…

</script>: closing script tag

Differences between Java programming language and Java Scripting language

1) Java is an object oriented programming language whereas JavaScript is a scripting


language.
2) JavaScript is used to make the web pages more interactive. However, Java can be used
not only to make interactive web pages but can also be used to create server side
applications and standalone programming.
3) Java uses the concept of classes and objects that makes reuse of the code easier but there
is no such thing in JavaScript.
4) Java exhibits the properties like inheritance, data encapsulation and polymorphism
whereas JavaScript does not.
5) Java can stand on its own while JavaScript must be placed inside an HTML document to
function

©Juliet 2023
Page 1
Introduction to JavaScript 2023

JavaScript Syntax:

A JavaScript consists of JavaScript statements that are placed within the <script>... </script>
HTML tags in a web page.

You can place the <script> tag containing your JavaScript anywhere within you web page but it
is preferred way to keep it within the <head> tags.

<script>

JavaScript code

</script>

Exercise1

An illustration on how to append/ write some output on an html page

Create an HTML page with some embedded JavaScript code to output the statement “This is my
first JavaScript page” when ran via web browser.

Exercise Two

Create an HTML page with some embedded JavaScript code to output the statements shown
below:-

1. HTML is a free language

2. HTML is user friendly

<html>

<Body>

©Juliet 2023
Page 2
Introduction to JavaScript 2023

<p>

An illustration on how to append JavaScript code into an HTML page:

</p>

<script>

document.write("<h1>This is my first JavaScript program</h2>");

document.write("<p>Java scripting is fun.</p>");

</script>

<p>JavaScript is different from java programming language</p>

</body>

</html>

Exercise 2

Java script functions

A function is a block of code that will be executed when the user calls it.

JavaScript alert function

An Alert function reacts to the event of user clicking on a button.

An illustration of the use of the alert () function to React to the user Event of clicking on a button
displayed on HTML page

©Juliet 2023
Page 3
Introduction to JavaScript 2023

Exercise one:

Create an HTML page with some embedded Java script code to create a button named “Click on
this button” which displays the output “Karibu Sana” when the user clicks on the button.

<html>

<head>

<title>alert function</title>

</head>

<Body>

<h1> JavaScript program</h1>

<p>

JavaScript can react to events such as the click of a button.

</p>

<button type="button" onclick="alert('Karibu Sana!')">Click on this button</button>

</body>

</html>

©Juliet 2023
Page 4
Introduction to JavaScript 2023

Website Maintenance

Web site maintenance refers to updating and keeping your site working properly. The benefits
of website maintenance include:-

1) it guarantees smooth functioning of a site,


2) It Ensures your website is up to date
Keeps your customers updated with the latest information about your company
Improves your company's brand image and aids in expansion
Helps to solve and monitor possible operational problems and avoids potential
catastrophes with clients..
3) Keeps the Website Up to date
4) Increases customer satisfaction

Website maintenance activities include:-

1) Checking broken links


2) Fixing bugs
3) Page titles
4) Correcting wrongly spelled texts
5) Adding new web pages
6) Checking if all the programmed forms are functioning
7) Site usage review
8) Browser testing

©Juliet 2023
Page 5

You might also like