Introduction JS Math
JS Syntax JS Dates
JS Statement JS Arrays
JS Comments JS Comparisons
JS Variables JS Conditions
JS Operators JS Loops
JS Arithmetic JS Type Conversion
JS Data Types JS Regular Expressions
JS Functions JS Debugging
JS Objects JS Hoisting
JS Scope JS Strict Mode
JS Events JS Forms
JS Strings JS Objects
JS Numbers JS DOM
JS Browser BOM
WHAT IS JAVASCRIPT
JavaScript is:
Is a lightweight, interpreted programming language.
used to create interactive effects within web browsers.
Designed for creating network-centric applications
Complementary to and integrated with Java
Complementary to and integrated with HTML
Open and cross-platform
JAVASCRIPT SYNTAX
A JavaScript consists of JavaScript statements that are placed
within the <script>... </script> HTML tags in a web page.
, The <script> tag alert the browser program to begin interpreting all the text between these tags
as a script. So simple syntax of your JavaScript will be as follows
JAVASCRIPT IN <HEAD> OR <BODY>
Scripts can be placed in the <body>, or in the <head> section of
an HTML page, or in both.
External JavaScript:
Scripts can also be placed in external files.
External scripts are practical when the same code is used in
many different web pages.
JavaScript files have the file extension .js.
<!DOCTYPE html>
<html>
<head>
<script src="firstScript.js"></script>
</head>
</html>
EXTERNAL JAVASCRIPT ADVANTAGES
Placing JavaScript in external files has some advantages:
It separates HTML and code
It makes HTML and JavaScript easier to read and maintain
Cached JavaScript files can speed up page loads
JAVASCRIPT FUNCTIONS AND EVENTS
A JavaScript function is a block of JavaScript code, that can be
executed when "asked" for.
For example, a function can be executed when an event occurs,
like when the user clicks a button.
SEMICOLONS ARE OPTIONAL
Simple statements in JavaScript are generally followed by a
semicolon character, just as they are in C, C++, and Java.
JavaScript, however, allows you to omit this semicolon if your statements are each placed on a
separate line. For example, the following code could be written without semicolons
<script language="javascrip”>
<!–
var1 = 10 var2 = 20
//--> </script>
CASE SENSITIVITY
JavaScript is a case-sensitive language. This means that language keywords, variables,
function names, and any other identifiers must always be typed with a consistent capitalization
of letters.