Lecture 4 JavaScript
Lecture 4 JavaScript
Lecture 4 JavaScript
Maithili Paranjape
Overview
Overview of JavaScript
Syntactic Characteristics
Primitives, Operations and Expressions
Introduction to JavaScript
JavaScript is a scripting language.
Why study JavaScript?
JavaScript is one of the 3 languages that all web developers should
learn:
HTML to define the content of web pages
CSS to specify the layout of web pages
JavaScript to program the behaviour of web pages web pages
Or indirectly, as a file
Either directly, as in
specified in the src
attribute of <script>, as
in
Debugging errors
Declaring Variables
document.write("Answer: “, result,
"<br>");
Typecasting required!
Finding elements by HTML id
function function_name([formal_parameters]) {
-- body –
}
Return value is the parameter of return
If there is no return or if return has no parameter, undefined is
returned
We place all function definitions in the head of the HTML
document
Calls to functions appear in the document body
Variables explicitly declared in a function are local
Registration of Event Handler