JavaScript
Chapter One
Overview of client-side web programing
What is JavaScript?
JavaScript: is a programming language for use in HTML pages.
What is the Difference Between HTML & CSS?
HTML: is the standard markup language for documents designed to be
displayed in a web browser.
CSS: is the language we use to style an HTML document.
Benefits or advantage of JavaScript
1. Speed: avaScript is a "interpreted" language, it cuts down on the time
needed for compilation in other programming languages like Java.
2. Simplicity: JavaScript is easy to understand and learn
3. Popularity: JavaScript is used everywhere in the web.
4. Server Load: Being client-side reduces the demand on the website
server.
5. Versatility: is an extremely versatile language.
Disadvantage of JavaScript
Client-side Security: The user can see the JavaScript code; it could be
misused by others.
Browser Support: Depending on the browser, JavaScript is interpreted
differently.
JavaScript Development Tools
1. Notepad++.
2. Microsoft FrontPage:
3. Adobe dream weaver cc.
4. Brackets.
JavaScript –Syntax
<Script ...>
JavaScript code
</script>
ZAKARIE A. ZABBAN 1
JavaScript
What can JavaScript Do?
• JavaScript can dynamically modify an HTML page
• JavaScript can react to user input
• JavaScript can validate user input
Where does JavaScript Fit In?
1. Client opens connection to server
2. Client sends request to server
3. Server sends response to client
4. Client and server close connection
The script tag takes two important attributes
1. Language: This attribute specifies what scripting language you are using.
2. Type: attribute specifies the type of button.
Uses JavaScript
1. Web application.
2. Web server.
3. Web development.
4. Display data and time
5. Mobile application
6. Client side validation
A white space: can be a sequence of spaces (entered using the space or the tab
keys)
A line break: (entered using the carriage return key (or the Enter key),or
<br/>).
Semicolons are Optional: Like many programming languages, JavaScript uses
the semicolon (;) to separate statements.
Comments in JavaScript: are hints that a programmer can add to make their
code easier to read and understand.
ZAKARIE A. ZABBAN 2
JavaScript
JavaScript-Placement: HTML, JavaScript code is inserted between <script>
and </script> tags.
Case Sensitivity: JavaScript is a case-sensitive language.
Chapter two
JAVASCRIPT – VARIABLES
Datatypes: is used define the type of value to be used in program.
In JavaScript, there are seven fundamental data types:
[Link] 2. String 3. Boolean 4. Null 5. Undefined 6. Symbol 7. Objet
JavaScript allows you to work with three primitive data types:
Numbers, e.g., 123, 120.50 etc.
Strings of text, e.g. "This text string" etc.
Boolean, e.g. true or false.
Defines two trivial data types
1. Null: This data type represents the intentional absence of a value, and is
represented by the keyword null (without quotes).
2. Undefined: This data type is denoted by the keyword undefined
(without quotes).
Variable: In programming, a variable is a container for a value.
In java Script variable we use either var or lets keyboard to declare variable
In java script there are three types of variables such as var, let, cons,
Example:
<script type="text/JavaScript">
var money;
var name;
</script>
ZAKARIE A. ZABBAN 3
JavaScript
JavaScript variable names: are case-sensitive.
JavaScript Reserved Words
Boolean static
Break super
byte switch
Catch This
Chapter-3
What is an Operator?
Operator is special sign used to perform operation to operators (value and
variable).
Constant is a type of variable whose value cannot be changed.
Types of operators.
1: Arithmetic Operators: is a mathematical function that takes two operands
and performs a calculation on them.
2: Comparison Operators: an compare numbers or strings and perform
evaluations.
3: Logical Operators: is used to combine two or more relation logically.
4: Assignment Operators: are used to assign the value or operators on the
variable.
5: Conditional Operators: are used to evaluate a condition that's applied to
one or two Boolean expressions.
Console
• The console is a panel that displays important messages, like errors, for
developers.
END
A Functions is JavaScript: is a set of statement that calculate of task or
variable value. To identifier the rules.
What is switch statement in JavaScript?
The switch statement: is a part of java script is conditional statement which are
used to perform different action based on different conditions.
ZAKARIE A. ZABBAN 4
JavaScript
Switch statement statement syntax
Switch statement
Case 1 true
execute statement
Case 2 true
execute statement break
End
execute default switch
Default
statement statement
Examples Of switch Statement.
Let Grade = “A”,
Switch (Grade)
{
Case ‘Excellent’:
[Link] (‘quilified’);
Break;
Defualt;
[Link] (order “Disquilified”);
}
ZAKARIE A. ZABBAN 5