SlideShare a Scribd company logo
Dasar PK
PPLG
Sinta Nurhayati, S.Pd
SMKN 6 Kota Tangerang
Selatan
Carilah sejarah JavaScript melalui
media yang kamu kuasai!
JAVASCRI
PT
JavaScript Basic
Dasar-Dasar Program Keahlian Program Perangakat Lunak dan Gim
Dasar-Dasar Program Keahlian Program Perangakat Lunak dan Gim
JavaScript Basic
Interpreter VS Compiler
Data Types
String
Numbers
Boolean
Null
Undefined
Data Types
Numbers
JS has one number type
• Positive numbers
• Negatives numbers
• Whole numbers
(integers)
• Decimal numbers
Math Operator
Comparison
Operator
Assignment
Operator
=
+=
-=
*=
/=
Logical
Operator
&&
(AND)
II (OR)
! (NOT)
NOT A NUMBER
NaN
NaN is a numeric value that represents something that
is...not a number
ex : 10/0
Variables
VARIABLES ARE LIKE LABELS
FOR VALUES
• We can store a value
and give it a name so
that we can:
• Refer back to it later
• Use that value to
do...stuff
Num
of
Votes
72
Basic Syntax
Make me a variable called "year" and give it the
value of 1987
Recall Values
CONST
Why Use Const
Once we cover Arrays & Objects, we'll see other
situations where const makes sense over let.
What is the value of totalScore?
What is the value of temperature?
What is the value of bankBalance?
What is the value of bankBalance?
What is the value of bankBalance?
CONDITIO
NALS
What do we choose?
Sleep or Play?
How should we do?
Go or Stop?
Making Decisions With Code
Which one prettier?
Dian Sastro or Pevita
Pearce
IF
STATEMEN
T
Only runs code if given condition is true
ELSE IF
If not the first thing, maybe this other thing??
ELSE IF
We can add multiple else ifs!
ELSE IF
If nothing else was true, do this...
NESTING
We can nest conditionals inside conditionals
TRUTHY AND FALSY
VALUES
• All JS values have an inherent truthyness or
falsyness about them
• Falsy values:
⚬ false
⚬ 0 "" (empty string) null
⚬ undefined
⚬ NaN
• Everything else is truthy!
LOGICAL
OPERATORS
Combining Expressions
AND
Both sides must be true, for the entire thing to be
true
AND
Both sides must be true, for the entire thing to be
true
OR
If one side is true, the entire thing is true
OR
If one side is true, the entire thing is true
NOT
!expression returns true if expression is false
JS LOOPS
REPEAT STUFF. REPEAT STUFF. REPEAT STUFF.
LOOPS
Loops allow us to repeat code
• "Print 'hello' 10 times
• Sum all numbers in an array
There are multiple types:
• for loop
• while loop
• for...of loop
• for...in loop
FOR LOOP SYNTAX
OUR FIRST FOR
LOOP
ANOTHER EXAMPLE
• Start i at 50
• Subtract 10 each
iteration
• Keep going as long
as i >= 0
INFINITE LOOPS
NESTED LOOPS
WHILE LOOPS
While loops continue running as long as the test
condition is true.
ARRAY
OUR FIRST DATA STRUCTURE
ARRAYS
Ordered collections of values.
• List of comments on IG post
• Collection of levels in a game
• Songs in a playlist
CREATING ARRAYS
ARRAYS ARE
INDEXED
Each element has a corresponding index (counting
starts at 0)
0 1 2 3 4 5 6
ARRAYS ARE
INDEXED
Each element has a corresponding index (counting
starts at 0)
NESTED ARRAYS
Each element has a corresponding index (counting
starts at 0)
OBJECT
OUR 2nd DATA STRUCTURE
HOW
WOULD
YOU
STORE
THIS?
USING AN OBJECT!
JS FUNCTIONS
REPEAT STUFF. REPEAT STUFF. REPEAT STUFF.
FUNCTIONS
A function definition (also called a function
declaration, or function statement) consists of the
function keyword, followed by :
• the name of function
• a list of parameters to the function, enclosed in
parentheses and separated by commas
• The javascript statements that define the
function, enclosed in curly braces, { /* ... */ }
OOP
Dasar-Dasar Program Keahlian Program Perangakat Lunak dan Gim
OOP LEARNING
OUTCOMES:
• Understand that in JavaScript most things are objects, and
you've probably used objects every time you've touched
JavaScript.
• Basic syntax: Object literals, properties and methods,
nesting objects and arrays in objects.
• Using constructors to create a new object.
Object Basics
• Object-oriented programming (OOP) is a programming
paradigm based on the concept of objects;
• We use objects to model (describe) real-world or abstract
features;
• Objects may contain data (properties) and code (methods). By
using objects, we pack data and the corresponding behavior
into one block;
• In OOP, objects are self-contained pieces/blocks of code;
• Objects are building blocks of applications, and interact with
one another;
• Interactions happen through a public interface (API) :
methods that the code outside of the object can access and
Object Basics
Data
Behavio
ur
Class and Instance
The 4 Fundamental
OOP Principal
Principal #1
Principal #2
Principal #3
Principal #4
Terima Kasih

More Related Content

PPT
Hub102 - JS - Lesson3
PDF
Build a virtual pet with javascript (april 2017)
PDF
Build a virtual pet with javascript (may 2017)
KEY
Java Building Blocks
PPTX
PYTHON PROGRAMMING PROBLEM SOLVING PPT DOCUMENTS PPT
PDF
Data handling CBSE PYTHON CLASS 11
PPTX
Introduction to Basics of Python
PDF
Init() day2
Hub102 - JS - Lesson3
Build a virtual pet with javascript (april 2017)
Build a virtual pet with javascript (may 2017)
Java Building Blocks
PYTHON PROGRAMMING PROBLEM SOLVING PPT DOCUMENTS PPT
Data handling CBSE PYTHON CLASS 11
Introduction to Basics of Python
Init() day2

Similar to Dasar-Dasar Program Keahlian Program Perangakat Lunak dan Gim (20)

PPTX
Presentation 2nd
PPTX
data handling revision.pptx
PDF
perl 6 hands-on tutorial
PPTX
python presentation.pptx
PDF
Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
PDF
LecccccccccccccProgrammingLecture-09.pdf
PPTX
Ruby basics
PPTX
An Introduction : Python
PPTX
unit1 python.pptx
PPTX
Android webinar class_java_review
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
PDF
Kaush, Vitali - Title: Exploring the Power of V5 Sensors in Robotics: Enhanci...
PPTX
Review old Pygame made using python programming.pptx
PPT
lec_4_data_structures_and_algorithm_analysis.ppt
PPT
lec_4_data_structures_and_algorithm_analysis.ppt
PPTX
Spreadsheets for developers
PPTX
bhaskars.pptx
PPTX
Autoboxing And Unboxing In Java
PPTX
06.pptx
Presentation 2nd
data handling revision.pptx
perl 6 hands-on tutorial
python presentation.pptx
Build a Virtual Pet with JavaScript (May 2017, Santa Monica)
LecccccccccccccProgrammingLecture-09.pdf
Ruby basics
An Introduction : Python
unit1 python.pptx
Android webinar class_java_review
Basic concept of Python.pptx includes design tool, identifier, variables.
Kaush, Vitali - Title: Exploring the Power of V5 Sensors in Robotics: Enhanci...
Review old Pygame made using python programming.pptx
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
Spreadsheets for developers
bhaskars.pptx
Autoboxing And Unboxing In Java
06.pptx
Ad

Recently uploaded (20)

PPTX
Presentation on HIE in infants and its manifestations
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
master seminar digital applications in india
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Cell Structure & Organelles in detailed.
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Institutional Correction lecture only . . .
PDF
Classroom Observation Tools for Teachers
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
Presentation on HIE in infants and its manifestations
STATICS OF THE RIGID BODIES Hibbelers.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
102 student loan defaulters named and shamed – Is someone you know on the list?
human mycosis Human fungal infections are called human mycosis..pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
master seminar digital applications in india
Microbial disease of the cardiovascular and lymphatic systems
Supply Chain Operations Speaking Notes -ICLT Program
Cell Structure & Organelles in detailed.
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
VCE English Exam - Section C Student Revision Booklet
Complications of Minimal Access Surgery at WLH
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
Institutional Correction lecture only . . .
Classroom Observation Tools for Teachers
O7-L3 Supply Chain Operations - ICLT Program
2.FourierTransform-ShortQuestionswithAnswers.pdf
Anesthesia in Laparoscopic Surgery in India
Ad

Dasar-Dasar Program Keahlian Program Perangakat Lunak dan Gim