JavaScript
Contents
01 02 03
Introduction Data Type & Variable Array
04 05 06
Object literal Conditional loop Function
used to write programs that run in
web pages.
JavaScript can control how a web page
looks or make the page respond when
JavaScript a viewer clicks a button or moves the
mouse.
like Gmail, Facebook, and Twitter use
JavaScript to make it easier to send
email, post comments, or browse
websites.
[Link](Something);
How to write [Link](Something);
JavaScript
[Link]("Something");
Data Types
Data Types
String Number BooleanString
Undefined Null Date and Object
Variables
Let
Var Const
Let num5 = 2; var num4 = 20; const techal = "Yoon";
[Link](num5); [Link](num4); [Link](techal);
Input from users Ask a Yes or No Question
Prompt Alert Confirm
var name = prompt("What's [Link]("Hello");
your name?");
alert("are you ready?");
[Link]("Hello " + name);
Types of JavaScript Operators
String Operators
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Ternary Operators
Type Operators
Types of JavaScript Operators
Arithmetic Operators Assignment Operators
Types of JavaScript Operators
Comparison Operators Logical Operators
Arrays and Methods
Methods
Adding Elements in Arrays
Arrays Push Method(FIFO) and
Unshift Method(LIFO)
let name=[”Kyaw”,”Aung”,”Ma”];
[Link](name); Removing Elements from an Array
Pop Method(removing last item) and
shift Method(removing first item)
Adding Arrays
[Link](otherArray) method
using comma
Turning an Array into a String
.join() method and + method
Objects
Objects
let student={
firstname:"Yoon",
age:31,
address:"60st”
}
[Link](student);
Conditional and
Loops
If Statement
If...else Statement
Chaining if...else Statements
While Loop
For Loop
Functions
Syntax of Function
Calling a Function
Passing Arguments into Functions
Passing Multiple Arguments to a Function
Returning Values from Functions
var double = function (number) {
return number * 2;
};
double(3);
//6
Returning Values from Functions
var double = function (number) {
return number * 2;
};
double(3);
//6
DOM
(Document Object Model)
Selecting DOM Elements
The browser converts the elements into a tree-like
structure.
This tree is known as the DOM tree
Using id to Identify Elements
<h1 id="main">Hello world!</h1>
Selecting an Element Using
getElementById
var headingElement = [Link]("main");
[Link];
Replacing the Heading Text Using the DOM
Thank you