KEMBAR78
JavaScript Basic | PPTX
https://fnurpandi.wordpress.com/
JavaScript
Finsa Nurpandi
finsa@unsur.ac.id
Universitas Suryakancana Cianjur
https://fnurpandi.wordpress.com/
https://fnurpandi.wordpress.com/
Operation System
Web Browser
SCRIPTING LANGUAGE
C++ Apps Java Apps .NET Apps
Web Page
JavaScript
can’t access local files
can’t directly access database
can’t access hardware
https://fnurpandi.wordpress.com/
JavaScript
is a
client-side language
https://fnurpandi.wordpress.com/
JavaScript
is not
java
https://fnurpandi.wordpress.com/
JavaScript
is
Interpreted
not
compiled
https://fnurpandi.wordpress.com/
Javascript
is
Case
Sensitive!
https://fnurpandi.wordpress.com/
alert(“Hello world”);
Alert(“Hello world”);
https://fnurpandi.wordpress.com/
JAVASCRIPT STATEMENT
alert(“hello world”); alert(“another message”);
This is realy realy realy realy realy realy realy realy complex message
https://fnurpandi.wordpress.com/
JAVASCRIPT IS WHITESPACE INSENSITIVE
alert(“hello world”);
alert( “hello world” );
alert
( “hello world”
);
alert(“hello world”);
https://fnurpandi.wordpress.com/
JAVASCRIPT COMMENT
//this is a comment
alert(“hello”); //this is a comment too
/*
this is
a multiple line
comment */
https://fnurpandi.wordpress.com/
WHERE TO PUT JAVASCRIPT
See the example...
https://fnurpandi.wordpress.com/
VARIABLES
var year;
var customerEmail;
var todaysdate;
var foo;
var x;
var 99problems;
var problems99;
letters
numbers
_
$
https://fnurpandi.wordpress.com/
VARIABLES DECLARATION
var, let, const
https://fnurpandi.wordpress.com/
VAR
https://fnurpandi.wordpress.com/
VAR
https://fnurpandi.wordpress.com/
LET
https://fnurpandi.wordpress.com/
LET
https://fnurpandi.wordpress.com/
LET
https://fnurpandi.wordpress.com/
LET
https://fnurpandi.wordpress.com/
CONST
https://fnurpandi.wordpress.com/
CONST
https://fnurpandi.wordpress.com/
CONST
https://fnurpandi.wordpress.com/
CONDITIONAL CODE
if ( condition ) {
// code goes here
// ...
} else {
// otherwise, different code
}
https://fnurpandi.wordpress.com/
OPERATORS AND
EXPRESSIONS
https://fnurpandi.wordpress.com/
ARITHMETIC OPERATORS
* / + -
https://fnurpandi.wordpress.com/
ASSIGNMENT OPERATORS
= += -= *= /=
https://fnurpandi.wordpress.com/
EQUALITY
= assignment
== equality
=== strict equality
https://fnurpandi.wordpress.com/
LOGICAL AND / OR
if ( a === b && c === d ) { ...
if ( a === b || c === d ) { ...
if ( (a > b) && (c < d) ) { ...
https://fnurpandi.wordpress.com/
MODULUS
var year = 2003;
var remainders = year % 4; // remainder is 3
https://fnurpandi.wordpress.com/
INCREMENT/DECREMENT
a = a + 1 a = a – 1
a += 1 a -= 1
a++; //postfix a--;
++a; //prefix --a;
https://fnurpandi.wordpress.com/
WORKING WITH LOOPS
https://fnurpandi.wordpress.com/
WHILE LOOP
var a = 1;
while ( a < number ) {
document.write(a);
a++;
}
https://fnurpandi.wordpress.com/
DO… WHILE LOOP
var a = 1;
do {
document.write(a);
a++;
} while ( a < number );
https://fnurpandi.wordpress.com/
FOR LOOP
for ( var i = 1; i < 10; i++) {
// do stuff
// do stuff
// do stuff
// etc..
}
https://fnurpandi.wordpress.com/
BREAK
for ( var i = 1; i < 100; i++) {
// do stuff
// do stuff
if ( i == 5) {
break;
}
// do stuff
}
// break jumps out the loop
https://fnurpandi.wordpress.com/
CONTINUE
for ( var i = 1; i < 100; i++) {
// do stuff
// do stuff
if ( i == 5) {
continue;
}
// do stuff
}
https://fnurpandi.wordpress.com/
FUNCTIONS
function myfunction (){
document.write (“test function”);
}
myFunction();
https://fnurpandi.wordpress.com/
FUNCTIONS WITH PARAMETER
function myfunction ( x,y ){
var result = x*y;
document.write(result);
}
myFunction(200,300);
https://fnurpandi.wordpress.com/
REFERENCES
• https://www.w3schools.com/js/
• https://javascript.info/
• https://www.tutorialspoint.com/javascript/
https://fnurpandi.wordpress.com/
The end.

JavaScript Basic