2. What is JavaScript?
JavaScript is a front-end scripting language
developed by Netscape for dynamic content.
It is a programming language that makes a
website interactive
It is lightweight and can be used as an
Object Oriented Language
3. How Was JavaScript Created?
It was first created by Brendan Eich at
Netscape in 1995
It was named Mocha during development
and released in beta as LiveScript
Ultimately named JavaScript to piggyback on
the popularity of Java for marketing reasons
4. JavaScript VS Java
JavaScript Java
Interpreted (not compiled) by client. Compiled byte codes downloaded from server,
executed on client.
Object-oriented. No distinction between types
of objects. Inheritance is through the prototype
mechanism, and properties and methods can be
added to any object dynamically.
Class-based. Objects are divided into classes
and instances with all inheritance through the
class hierarchy. Classes and instances cannot
have properties or methods added dynamically.
Code integrated with, and embedded in,
HTML.
Applets distinct from HTML (accessed from
HTML pages
Variable data types not declared (dynamic
typing).
Variable data types must be declared (static
typing).
Cannot automatically write to hard disk. Cannot automatically write to hard disk
5. When is JavaScript Executed?
JavaScript code is Executed during the page
loading or when the browser fires an event
All statements are executed at page loading
Some statements define functions that can
be called later
6. Why JavaScript is Widely Used?
JavaScript is the only client-side scripting
language
It runs in a browser so you don’t need to
download any software to use it
A web page can be used without a
JavaScript but using JavaScript improves a
visitor’s experience
7. Some Advantages Of JavaScript
JavaScript allows interactivity such as:
Implementing form validation
Content loading and changing dynamically
Implementing AJAX functionality
8. Some Advantages of JavaScript
Can read and write HTML element and
modify the DOM structure
Can handle exceptions
9. Using The JavaScript Code
The JavaScript code can be placed in the
<script> tag in the head
<script> tag in the body
There are two types of files used with the
JavaScript language:
10. 1) Including it’s code in any other file for
example an HTML file or in any other script
or non script-based file
2) The file in this case would have the
extension appropriate to the type of file for
example .htm or .html for an HTML file.
3) Another way is to create a file that uniquely
contains JavaScript code with .js extension
11. Writing the First JavaScript
<html>
<body>
<head>
<script type="text/javascript">
document.write('Hello JavaScript!');
</script>
</head>
</body>
</html>
14. The way that document content is accessed
and modified is called the Document Object
Model, or DOM. The Objects are organized
in a hierarchy. This hierarchical structure
applies to the organization of objects in a
Web document.
Window object: Top of the hierarchy. It is
the outmost element of the object hierarchy.
15. Document object: Each HTML document
that gets loaded into a window becomes a
document object. The document contains the
content of the page.
Form object: Everything enclosed in the
<form>...</form> tags sets the form object.
Form control elements: The form object
contains all the elements defined for that
object such as text fields, buttons, radio
buttons, and checkboxes.
16. Implementation Of JavaScript
Rhino is an open-source implementation of
JavaScript written entirely in java.
It is typically embedded into java applications
to provide scripting to end users.
17. Conclusion
JavaScript is a programming language that is
widely used and will become more popular in
the future with the advancement of
technology.
It is also used an Object Oriented Language