Javascript 1 - Basic JavaScript
Javascript 1 - Basic JavaScript
1
Objectives
2
Describe JavaScript
Control Structure
Functions
What is JavaScript
3
pages.
JavaScript in Firefox
JavaScript in Chrome
<html>
<head>
<script language = "JavaScript">
confirm ("Are you Sure?");
alert("OK");
document.write("Thank You!");
</script>
</head>
</html>
JavaScript Comments
9
// line comment
/* Block comment */
Variables
10
combined.
Example: var x = 'This apple costs = ' +
5;
will result in a string with value "This apple costs =
5".
Primitive Data Type
13
– AND (&&)
– OR (||)
– NOT (!)
String Operator
18
x = "yellow";
y = "green";
z = x + y + "white";
which means z is “yellowgreenwhite”
w = y + 9, which means w is “green9”
Evaluation Operator
19
document.write(typeof(x));
Operator Precedence
20
includes:
– Exec, Test, Match, Search, Replace, Split
The syntax to use a method:
objectname.method = function_name
The syntax for calling the method in the context of the
object is:
objectname.methodname(parameters)
https://www.w3schools.com/js/js_regexp.asp
Method for JS regular expressions
23
Function
24
JavaScript has several pre-defined functions that we can use within the script.
statements;
}
• Calling a Function
• Return Statement
Q&A
25
Exercise
26
https://www.w3schools.com/js/js_exercises.asp
http://
www.asmarterwaytolearn.com/js/index-of-exercises.h
tml
Debugging
27