SlideShare a Scribd company logo
Introduction to
Javascript & Typescript
Rony Setyawan,S.T.,M.Kom.
What is JavaScript ?
JavaScript is a programming language. It is lightweight and most commonly used as a part of web
pages. It is an interpreted programming language with object-oriented capabilities.
JavaScript can execute not only in the browser, but also on the server, or actually on any device that
has a special program called the JavaScript engine.
Javascript is single-threaded, non-blocking,
asynchronous, concurrent language.
● Single-threaded means that it runs only one thing at a
time.
● Non-blocking & Asynchronous means that it doesn't
wait for the response of an API call, I/O events, etc.,
and can continue the code execution.
● Concurrent means executing multiple tasks at the
same time but not simultaneously. E.g. two tasks works
in overlapping time periods.
For more information, watch this video
What is JavaScript ?
● Easy to Learn
● Popularity
● Large Community
● Speed
● Versatility
● Interoperability
Why Use JavaScript ?
Javascript Code Structure
Single Statement
; is Semicolon
Variable
Variable is a “named storage” for data. We can use variable to store any data
you need.
In package delivery apps, there’s information about package details, address,
sender’s name, etc.
Variable are used to store all the information.
Example
Code Example
Create (declare) variable
String “Hello”
Store data using assignment operator “=”
Different ways to declare variable :
● var : To create global variables
● let : To create scoped, replaceable variables
● const : Can’t be updated or redeclared within
the scope
Variable Declaration
Variable Naming
● Must contain only letters, digits, or the symbols “$” and “_”
● The first character must not digit
● Case-sensitive
● Can’t use reserved words
A value in JavaScript is always of a certain type.
Primitive data types : The predefined data types provided by JavaScript.
Non-primitive data types : The data types that are derived from primitive data types.
Primitive
String Used to represent textual data
Number & BigInt Used to hold decimal values as well as values without
decimals
Boolean Represents a logical entity and can have two values:
true and false
Null Has exactly one value: null. Represents the
intentional absence of any object value
Undefined A variable that has not been assigned a value has the
value undefined
Data Types
Non Primitive
Object Is an entity having properties and methods (keyed
collection) → Will be explained in the next session
Array Used to store more than one element under a single
variable → Will be explained in the next session
Data Types
Mutable vs Immutable
● Mutable is a type of variable that can be changed. (contains of: non primitive) it
is also called as reference type
● Immutable are the objects whose state cannot be changed once the objects is
created. (contains of: primitive) immutable it is also called as value type.
● Declaring variable with const doesn’t make the value immutable. It depends
on data type.
Mutable vs Immutable
Value types are been stored on the Stack in our memory.
When storing a value type in memory, it adds an element to the top of the stack with the value of the
newly created variable. When creating a new variable and assigned the first one to the new one, it
adds a new element on top of the stack with the value of the new variable.
“Jhonny”
The Stack
“Jhonny”
1
2
The first variable — name gets into the stack
with the value of the variable data. Then, the
newName gets into the stack in a new
memory location with the value of the
variable data.
Mutable vs Immutable
Reference types are been stored on
the Heap. The Heap, indifference from
the stack, has no order of how to store
the data.
When storing a reference type in
memory, it adds a new element to the
top of the stack, when its value is a
pointer/reference to the address of the
object that has been stored on the
heap.
“Jhonny”
The Stack
“Jhonny”
1
2
PersonPointer
3
newPerson Pointer
4
The Heap
{
name: ‘Jhonny’,
age: 26
}
Mutable vs Immutable
Immutable
Tr y t o c h a n g e v a l u e i n
newName variable, check out
the result!
Does that change name variable
value?
“Jhonny”
The Stack
“Jhonny”
1
2
PersonPointer
3
newPerson Pointer
4
The Heap
{
name: ‘Jhonny’,
age: 26
}
Mutable vs Immutable
Mutable
T r y t o c h a n g e v a l u e i n
newPerson variable, check out
the result!
Does that change Person
variable value?
“Jhonny”
The Stack
“Jhonny”
1
2
PersonPointer
3
newPerson Pointer
4
The Heap
{
name: ‘Jhonny’,
age: 26
}
With that in mind, we can say
that a value type is immutable
where a reference type is
mutable.
Mutable vs Immutable
“Jhonny”
The Stack
“Jhonny”
1
2
PersonPointer
3
newPerson Pointer
4
The Heap
{
name: ‘Jhonny’,
age: 26
}
● padStart
● padEnd
● chartAt
● charCodeAt
● split
● indexOf
● lastIndexOf
● search
String Built-in Method
● slice
● substring
● substr
● replace
● toUpperCase
● toLowerCase
● concat
● trim
https://developer.mozilla.org/en-US/docs/Web/JavaScript/
Reference/Global_Objects/String
Template Literals
● Template literals (template strings) allow you to
use strings or embedded expressions in the form
of a string.
● Template literals are enclosed by backtick (`)
characters instead of double or single quotes.
● With template literals, you can get :
○ A multiline string → a string that can span multiple lines.
○ String formatting → the ability to substitute part of the
string for the values of variables or expressions. This
feature is also called string interpolation.
○ HTML escaping → the ability to transform a string so that
it’s safe to include in HTML.
Global built-in method & property
● Number
● parseInt
● parseFloat
● MAX_VALUE
● MIN_VALUE
● POSITIVE_INFINITY
● NEGATIVE_INFINITY
● NaN
Number Built-in Method
Number built-in method
● toString
● toExponential
● toFixed
● toPrecision
● valueOf
Type Conversion
● String Conversion
○ String(123) // return a string from a number
literal 123
● Numeric Conversion
○ const num = "3" * "3" // return 9 in number
○ Number("3.14") // return 3.14 in number
● Boolean Conversion
○ Boolean(1) // return true
○ Boolean(0) // return false
○ Boolean("Hello") // return true
○ Boolean("") // return false
Date Data Type
It stores the date, time and provides methods for date/time management.
Set Methods
● setDate
● setFullYear
● setHours
● setMilliseconds
● setMinutes
● setMonth
● setSeconds
● setTime
Date Built-in Method
Get Methods
● getFullYear
● getMonth
● getDate
● getHours
● getMinutes
● getSeconds
● getMilliseconds
● getTime
● getDay
● Date.now
● Date.parse
Basic Operators
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder (modulo)
** Exponentiation
● An operand is what operators are applied to. For instance, in the multiplication of 5
* 2 there are two operands: the left operand is 5 and the right operand is 2.
Sometimes, people call these “arguments” instead of “operands”.
Unary,Binary and Operand
● An operator is unary if it has a single operand. For example, the
unary negation - reverses the sign of a number.
● An operator is binary if it has two operands. The same minus exists
in binary form as well.
Note : Only work with binary “+”. Other arithmetic operators work only with numbers and always convert their operands to numbers.
String Concatenation with binary“+”
Modify in Place
We often need to apply an operator to a variable and store the new result in that
same variable.
Increment & Decrement
● Increasing or decreasing a number by one is among the most common
numerical operations.
● Increment ++ increases a variable by 1.
● Decrement -- decreases a variable by 1
Postfix & Prefix Form
● The operators ++ and -- can be placed either before or after a variable.
● When the operator goes after the variable, it is in “postfix form”: counter++.
● The “prefix form” is when the operator goes before the variable: ++counter.
● If we’d like to increase a value and immediately use the result of the operator, we need the prefix form
● If we’d like to increment a value but use its previous value, we need the postfix form
Comparison Operators
Comparison operators
are used in logical
statements to determine
equality or difference
between variables or
values.
Given that x = 5, this
table would explains the
comparison operators
What is TypeScript?
TypeScript is a superset of JavaScript, which means that it adds additional features
to JavaScript, but does not break any existing JavaScript code.
The main feature that TypeScript adds is static typing, which allows developers to
specify the types of data that variables and functions can hold. This can help to
catch errors early in the development process and make code more maintainable.
Why use TypeScript?
There are several benefits to using TypeScript, including:
● Improved type safety: TypeScript's static type checking can help to catch errors early in
the development process, which can save time and frustration.
● Better code readability: TypeScript's type annotations can make code more readable
and easier to understand.
● Increased developer productivity: TypeScript can help developers to be more
productive by catching errors early and making code more maintainable.
To get started with TypeScript, you can follow these steps:
● Install TypeScript: You can install TypeScript using npm or yarn.
● Create a TypeScript file: Create a file with a .ts extension.
● Write TypeScript code: You can write TypeScript code using the same syntax as
JavaScript.
● Compile TypeScript code: You can compile TypeScript code into JavaScript
code using the TypeScript compiler.
● Reference : https://www.typescriptlang.org/docs/handbook/typescript-tooling-
in-5-minutes.html
Getting started with TypeScript
Example
Resources
TypeScript-documentation: https://www.typescriptlang.org/docs
TypeScript-Handbook: https://www.typescriptlang.org/docs/handbook/intro.html
TypeScript-tutorials: https://www.freecodecamp.org/news/learn-typescript-
beginners-guide
Exercises
Task Expectation
Write a code to find area of rectangle Input: length = 5, width = 3
Output: 15
Write a code to find diameter, circumference
and area of a circle
Input: radius = 5
Output : diameter = 10, circumference =
31.4159, area = 78.539
Write a code to find angles of triangle if two
angles are given
Input: a = 80, b = 65
Output: 35
Write a code to get difference between dates
in days.
Input: date1 = 2024-03-19, date2 =
2024-03-21
Output: 2
Write a code to print your name initial in
uppercase
Input: John Doe
Output: JD

More Related Content

Similar to Introduction to Javascript and Typescript.pdf (20)

Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming LanguageSwift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Hossam Ghareeb
 
basics dart.pdf
basics dart.pdfbasics dart.pdf
basics dart.pdf
ssuser0ca68e
 
Typescript
TypescriptTypescript
Typescript
Nikhil Thomas
 
Unit 2 python
Unit 2 pythonUnit 2 python
Unit 2 python
praveena p
 
Python unit 2 is added. Has python related programming content
Python unit 2 is added. Has python related programming contentPython unit 2 is added. Has python related programming content
Python unit 2 is added. Has python related programming content
swarna16
 
Programming in python - Week 2
Programming in python - Week 2Programming in python - Week 2
Programming in python - Week 2
Priya Nayak
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
rohithprabhas1
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
 
12.6-12.9.pptx
12.6-12.9.pptx12.6-12.9.pptx
12.6-12.9.pptx
WinterSnow16
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
Terry Yoast
 
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Tutort Academy
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
Connex
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
Fernando Torres
 
PYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day lifePYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Jitendra Bafna
 
Python: An introduction A summer workshop
Python: An  introduction A summer workshopPython: An  introduction A summer workshop
Python: An introduction A summer workshop
ForrayFerenc
 
Presentation of Python Programming Language
Presentation of Python Programming LanguagePresentation of Python Programming Language
Presentation of Python Programming Language
DeepakYaduvanshi16
 
Pc module1
Pc module1Pc module1
Pc module1
SANTOSH RATH
 
UNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptxUNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptx
shilpar780389
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
Shoaib Ghachi
 
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming LanguageSwift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Hossam Ghareeb
 
Python unit 2 is added. Has python related programming content
Python unit 2 is added. Has python related programming contentPython unit 2 is added. Has python related programming content
Python unit 2 is added. Has python related programming content
swarna16
 
Programming in python - Week 2
Programming in python - Week 2Programming in python - Week 2
Programming in python - Week 2
Priya Nayak
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
rohithprabhas1
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
Terry Yoast
 
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
Tutort Academy
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
Connex
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
Fernando Torres
 
PYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day lifePYTHON PPT.pptx python is very useful for day to day life
PYTHON PPT.pptx python is very useful for day to day life
NaitikSingh33
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Jitendra Bafna
 
Python: An introduction A summer workshop
Python: An  introduction A summer workshopPython: An  introduction A summer workshop
Python: An introduction A summer workshop
ForrayFerenc
 
Presentation of Python Programming Language
Presentation of Python Programming LanguagePresentation of Python Programming Language
Presentation of Python Programming Language
DeepakYaduvanshi16
 
UNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptxUNIT – 2 Features of java- (Shilpa R).pptx
UNIT – 2 Features of java- (Shilpa R).pptx
shilpar780389
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
Shoaib Ghachi
 

More from rony setyawansyah (8)

Ownership in Rust (Concept,Theory,Practices)
Ownership in Rust (Concept,Theory,Practices)Ownership in Rust (Concept,Theory,Practices)
Ownership in Rust (Concept,Theory,Practices)
rony setyawansyah
 
Design Algoritma Pemrograman Tingkat Lanjut
Design Algoritma Pemrograman Tingkat LanjutDesign Algoritma Pemrograman Tingkat Lanjut
Design Algoritma Pemrograman Tingkat Lanjut
rony setyawansyah
 
Software Development Practice : Test-Driven Development
Software Development Practice : Test-Driven DevelopmentSoftware Development Practice : Test-Driven Development
Software Development Practice : Test-Driven Development
rony setyawansyah
 
SOLID Principle & Design Pattern.pdf
SOLID Principle & Design Pattern.pdfSOLID Principle & Design Pattern.pdf
SOLID Principle & Design Pattern.pdf
rony setyawansyah
 
Algorithm Analysis & Solution Design.pdf
Algorithm Analysis & Solution Design.pdfAlgorithm Analysis & Solution Design.pdf
Algorithm Analysis & Solution Design.pdf
rony setyawansyah
 
Requirement Engineering.pdf
Requirement Engineering.pdfRequirement Engineering.pdf
Requirement Engineering.pdf
rony setyawansyah
 
Introduction of Software Architect(Definition, Mindset, Process).pptx
Introduction of Software Architect(Definition, Mindset, Process).pptxIntroduction of Software Architect(Definition, Mindset, Process).pptx
Introduction of Software Architect(Definition, Mindset, Process).pptx
rony setyawansyah
 
Distributed Transaction in Microservices.pdf
Distributed Transaction in Microservices.pdfDistributed Transaction in Microservices.pdf
Distributed Transaction in Microservices.pdf
rony setyawansyah
 
Ownership in Rust (Concept,Theory,Practices)
Ownership in Rust (Concept,Theory,Practices)Ownership in Rust (Concept,Theory,Practices)
Ownership in Rust (Concept,Theory,Practices)
rony setyawansyah
 
Design Algoritma Pemrograman Tingkat Lanjut
Design Algoritma Pemrograman Tingkat LanjutDesign Algoritma Pemrograman Tingkat Lanjut
Design Algoritma Pemrograman Tingkat Lanjut
rony setyawansyah
 
Software Development Practice : Test-Driven Development
Software Development Practice : Test-Driven DevelopmentSoftware Development Practice : Test-Driven Development
Software Development Practice : Test-Driven Development
rony setyawansyah
 
SOLID Principle & Design Pattern.pdf
SOLID Principle & Design Pattern.pdfSOLID Principle & Design Pattern.pdf
SOLID Principle & Design Pattern.pdf
rony setyawansyah
 
Algorithm Analysis & Solution Design.pdf
Algorithm Analysis & Solution Design.pdfAlgorithm Analysis & Solution Design.pdf
Algorithm Analysis & Solution Design.pdf
rony setyawansyah
 
Introduction of Software Architect(Definition, Mindset, Process).pptx
Introduction of Software Architect(Definition, Mindset, Process).pptxIntroduction of Software Architect(Definition, Mindset, Process).pptx
Introduction of Software Architect(Definition, Mindset, Process).pptx
rony setyawansyah
 
Distributed Transaction in Microservices.pdf
Distributed Transaction in Microservices.pdfDistributed Transaction in Microservices.pdf
Distributed Transaction in Microservices.pdf
rony setyawansyah
 
Ad

Recently uploaded (20)

Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
“Solving Tomorrow’s AI Problems Today with Cadence’s Newest Processor,” a Pre...
Edge AI and Vision Alliance
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Ad

Introduction to Javascript and Typescript.pdf

  • 1. Introduction to Javascript & Typescript Rony Setyawan,S.T.,M.Kom.
  • 2. What is JavaScript ? JavaScript is a programming language. It is lightweight and most commonly used as a part of web pages. It is an interpreted programming language with object-oriented capabilities. JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine.
  • 3. Javascript is single-threaded, non-blocking, asynchronous, concurrent language. ● Single-threaded means that it runs only one thing at a time. ● Non-blocking & Asynchronous means that it doesn't wait for the response of an API call, I/O events, etc., and can continue the code execution. ● Concurrent means executing multiple tasks at the same time but not simultaneously. E.g. two tasks works in overlapping time periods. For more information, watch this video What is JavaScript ?
  • 4. ● Easy to Learn ● Popularity ● Large Community ● Speed ● Versatility ● Interoperability Why Use JavaScript ?
  • 5. Javascript Code Structure Single Statement ; is Semicolon
  • 6. Variable Variable is a “named storage” for data. We can use variable to store any data you need.
  • 7. In package delivery apps, there’s information about package details, address, sender’s name, etc. Variable are used to store all the information. Example
  • 8. Code Example Create (declare) variable String “Hello” Store data using assignment operator “=”
  • 9. Different ways to declare variable : ● var : To create global variables ● let : To create scoped, replaceable variables ● const : Can’t be updated or redeclared within the scope Variable Declaration
  • 10. Variable Naming ● Must contain only letters, digits, or the symbols “$” and “_” ● The first character must not digit ● Case-sensitive ● Can’t use reserved words
  • 11. A value in JavaScript is always of a certain type. Primitive data types : The predefined data types provided by JavaScript. Non-primitive data types : The data types that are derived from primitive data types. Primitive String Used to represent textual data Number & BigInt Used to hold decimal values as well as values without decimals Boolean Represents a logical entity and can have two values: true and false Null Has exactly one value: null. Represents the intentional absence of any object value Undefined A variable that has not been assigned a value has the value undefined Data Types Non Primitive Object Is an entity having properties and methods (keyed collection) → Will be explained in the next session Array Used to store more than one element under a single variable → Will be explained in the next session
  • 13. Mutable vs Immutable ● Mutable is a type of variable that can be changed. (contains of: non primitive) it is also called as reference type ● Immutable are the objects whose state cannot be changed once the objects is created. (contains of: primitive) immutable it is also called as value type. ● Declaring variable with const doesn’t make the value immutable. It depends on data type.
  • 14. Mutable vs Immutable Value types are been stored on the Stack in our memory. When storing a value type in memory, it adds an element to the top of the stack with the value of the newly created variable. When creating a new variable and assigned the first one to the new one, it adds a new element on top of the stack with the value of the new variable. “Jhonny” The Stack “Jhonny” 1 2 The first variable — name gets into the stack with the value of the variable data. Then, the newName gets into the stack in a new memory location with the value of the variable data.
  • 15. Mutable vs Immutable Reference types are been stored on the Heap. The Heap, indifference from the stack, has no order of how to store the data. When storing a reference type in memory, it adds a new element to the top of the stack, when its value is a pointer/reference to the address of the object that has been stored on the heap. “Jhonny” The Stack “Jhonny” 1 2 PersonPointer 3 newPerson Pointer 4 The Heap { name: ‘Jhonny’, age: 26 }
  • 16. Mutable vs Immutable Immutable Tr y t o c h a n g e v a l u e i n newName variable, check out the result! Does that change name variable value? “Jhonny” The Stack “Jhonny” 1 2 PersonPointer 3 newPerson Pointer 4 The Heap { name: ‘Jhonny’, age: 26 }
  • 17. Mutable vs Immutable Mutable T r y t o c h a n g e v a l u e i n newPerson variable, check out the result! Does that change Person variable value? “Jhonny” The Stack “Jhonny” 1 2 PersonPointer 3 newPerson Pointer 4 The Heap { name: ‘Jhonny’, age: 26 }
  • 18. With that in mind, we can say that a value type is immutable where a reference type is mutable. Mutable vs Immutable “Jhonny” The Stack “Jhonny” 1 2 PersonPointer 3 newPerson Pointer 4 The Heap { name: ‘Jhonny’, age: 26 }
  • 19. ● padStart ● padEnd ● chartAt ● charCodeAt ● split ● indexOf ● lastIndexOf ● search String Built-in Method ● slice ● substring ● substr ● replace ● toUpperCase ● toLowerCase ● concat ● trim https://developer.mozilla.org/en-US/docs/Web/JavaScript/ Reference/Global_Objects/String
  • 20. Template Literals ● Template literals (template strings) allow you to use strings or embedded expressions in the form of a string. ● Template literals are enclosed by backtick (`) characters instead of double or single quotes. ● With template literals, you can get : ○ A multiline string → a string that can span multiple lines. ○ String formatting → the ability to substitute part of the string for the values of variables or expressions. This feature is also called string interpolation. ○ HTML escaping → the ability to transform a string so that it’s safe to include in HTML.
  • 21. Global built-in method & property ● Number ● parseInt ● parseFloat ● MAX_VALUE ● MIN_VALUE ● POSITIVE_INFINITY ● NEGATIVE_INFINITY ● NaN Number Built-in Method Number built-in method ● toString ● toExponential ● toFixed ● toPrecision ● valueOf
  • 22. Type Conversion ● String Conversion ○ String(123) // return a string from a number literal 123 ● Numeric Conversion ○ const num = "3" * "3" // return 9 in number ○ Number("3.14") // return 3.14 in number ● Boolean Conversion ○ Boolean(1) // return true ○ Boolean(0) // return false ○ Boolean("Hello") // return true ○ Boolean("") // return false
  • 23. Date Data Type It stores the date, time and provides methods for date/time management.
  • 24. Set Methods ● setDate ● setFullYear ● setHours ● setMilliseconds ● setMinutes ● setMonth ● setSeconds ● setTime Date Built-in Method Get Methods ● getFullYear ● getMonth ● getDate ● getHours ● getMinutes ● getSeconds ● getMilliseconds ● getTime ● getDay ● Date.now ● Date.parse
  • 25. Basic Operators Operator Description + Addition - Subtraction * Multiplication / Division % Remainder (modulo) ** Exponentiation
  • 26. ● An operand is what operators are applied to. For instance, in the multiplication of 5 * 2 there are two operands: the left operand is 5 and the right operand is 2. Sometimes, people call these “arguments” instead of “operands”. Unary,Binary and Operand ● An operator is unary if it has a single operand. For example, the unary negation - reverses the sign of a number. ● An operator is binary if it has two operands. The same minus exists in binary form as well.
  • 27. Note : Only work with binary “+”. Other arithmetic operators work only with numbers and always convert their operands to numbers. String Concatenation with binary“+”
  • 28. Modify in Place We often need to apply an operator to a variable and store the new result in that same variable.
  • 29. Increment & Decrement ● Increasing or decreasing a number by one is among the most common numerical operations. ● Increment ++ increases a variable by 1. ● Decrement -- decreases a variable by 1
  • 30. Postfix & Prefix Form ● The operators ++ and -- can be placed either before or after a variable. ● When the operator goes after the variable, it is in “postfix form”: counter++. ● The “prefix form” is when the operator goes before the variable: ++counter. ● If we’d like to increase a value and immediately use the result of the operator, we need the prefix form ● If we’d like to increment a value but use its previous value, we need the postfix form
  • 31. Comparison Operators Comparison operators are used in logical statements to determine equality or difference between variables or values. Given that x = 5, this table would explains the comparison operators
  • 32. What is TypeScript? TypeScript is a superset of JavaScript, which means that it adds additional features to JavaScript, but does not break any existing JavaScript code. The main feature that TypeScript adds is static typing, which allows developers to specify the types of data that variables and functions can hold. This can help to catch errors early in the development process and make code more maintainable.
  • 33. Why use TypeScript? There are several benefits to using TypeScript, including: ● Improved type safety: TypeScript's static type checking can help to catch errors early in the development process, which can save time and frustration. ● Better code readability: TypeScript's type annotations can make code more readable and easier to understand. ● Increased developer productivity: TypeScript can help developers to be more productive by catching errors early and making code more maintainable.
  • 34. To get started with TypeScript, you can follow these steps: ● Install TypeScript: You can install TypeScript using npm or yarn. ● Create a TypeScript file: Create a file with a .ts extension. ● Write TypeScript code: You can write TypeScript code using the same syntax as JavaScript. ● Compile TypeScript code: You can compile TypeScript code into JavaScript code using the TypeScript compiler. ● Reference : https://www.typescriptlang.org/docs/handbook/typescript-tooling- in-5-minutes.html Getting started with TypeScript
  • 37. Exercises Task Expectation Write a code to find area of rectangle Input: length = 5, width = 3 Output: 15 Write a code to find diameter, circumference and area of a circle Input: radius = 5 Output : diameter = 10, circumference = 31.4159, area = 78.539 Write a code to find angles of triangle if two angles are given Input: a = 80, b = 65 Output: 35 Write a code to get difference between dates in days. Input: date1 = 2024-03-19, date2 = 2024-03-21 Output: 2 Write a code to print your name initial in uppercase Input: John Doe Output: JD