SlideShare a Scribd company logo
Introduction to Programming
with JavaScript
Week 4: Object, Array
Jeongbae Oh

YCC JavaScript Seminar

2017.10.30
Object and Array
• Since primitive data types cannot be changed
("immutable"), a more complicated form of data
needs something else to be stored as information.

• Object (객체) and array (배열) are most frequently used
form of data structure in JavaScript.

• Object and array allows for complex manipulation
and operation of data.
Object
• Almost all values that is not a primitive
type or an operator is an object.

• Object consists of property and
method.
Object
• Properties are "status" or "characteristics" of
an object.

• Properties are composed of key-value pair,

• Methods are the "actions" that an object takes.

• Example: car (object), color (property),
accelerate (method)
Object
• var name = { [key: value] }; or 

var name = new Object(); 

• Keys and values are optional (i.e. an empty object is allowed).

• But a key must have its value.
Property
• Key has to be unique (i.e. no repeating keys).

• Key can be a string or a number.

("" is not used for keys)

• Value does not have to be unique.

• Value can hold almost any data type.

(Number, string, boolean, another object, function*, etc.)
Property
• Property can be accessed by: object.key or object[key];

• If the property's key is a number, the latter must be used.

• Property can be created/changed similarly to assigning a value to a variable.

• object.newKey = "newValue";
Method
• A property whose value is a function is called a method.

• Since it's a function, it has to include () at the end when calling.
Array Object
• Array is a special type of object that is
one-dimensional list.

• Items in an array is called an element.

• Array does not use key-value pairs.
Creating Array
• Empty

• var arrayName = []; or 

var arrayName = new Array();

• With elements

• var arrayName = [1, 2, 3]; 

• Elements can be of almost any data type.
Indexing
• As array does not have keys, its elements have to be
accessed by using index (position of element within
array).

arrayName[index];
• In programming, index starts with 0, instead of 1.
Array Properties & Methods
• arrayName.length; 

• arrayName.indexOf(value);

→ Returns index of the value

• arrayName.push(element); 

→ Returns index of added
element

• arrayName.pop();

→ Returns removed value

String Object
• string.includes() 

• string.startsWith() 

• string.endsWith() 

• string.split()
String Object
• string.slice() or

string.substring()

• string.toLowerCase() 

• string.toUpperCase() 

• string.trim() 

• string.length (property)
Number Object
• Number.isFinite() 

• Number.isInteger() 

• Number.isNaN() 

• Number.parseFloat() 

• Number.parseInt()
• number.toExponential()*

• number.toString()*
Date Object
• Allows calculation of date/time

• Time is assigned when called/
initialized

• Date object's methods allow
formatting date within string.

• getMonth() starts with 0, not 1
UNIX Time
• JavaScript uses UNIX time, which means the beginning (time 0) is defined as
1970-01-01 00:00:00.000 (UTC).

• All times are calculated in relation to the time 0.

• 86399999: 1970-01-01 23:59:59.999 (UTC)

• 1509346681342: 2017-10-30 06:58:01.342 (UTC)

• This number is called a timestamp.

• Browser automatically formats time in the local/server time, but calculations
must be done based on UTC.
Date Object
• Dates can be created/calculated using UNIX time.
• Dates can also be created using time string.
JSON
• JavaScript Object Notation

• Constructed the same way as an object

• Used to transfer data in various settings
(web, app, database, API server, etc.)
JSON for API
• Example: Foursquare API

• Developer sign up: https://ko.foursquare.com/
developers/apps

• Developer documentation: https://
developer.foursquare.com/docs
JSON for API
https://api.foursquare.com/v2/venues/
search?v=20171030&m=foursquare&

client_id=[CLIENT_ID]&client_secret=[CLIE
NT_SECRET]&ll=[COORDINATES]
Client API Server
{"meta":{"code":
200,"requestId":"59fbf3496a607142ba7a7d
f4"},"response":{"venues":
[{"id":"5340142111d247f646bce6f6","name
":"4x4","location":{"lat":
37.557804107666016,"lng":
126.93865203857422,"labeledLatLngs":
[{"label":"display","lat":
37.557804107666016,"lng":
126.93865203857422}], ...
• Searching for venues around a specific coordinate
JSON for API
• Response (use JSON formatter Chrome extension)
JSON for API
• Response (JSON formatter extension used)
JSON for API
• Using loops to process raw data
JSON for API
• Refining data to find insights
Object-Oriented Programming (OOP)
• JavaScript can also be used as an OOP language such as
Java. (But no real connection to Java, of course.)

• OOP is a programming paradigm which centers around
making objects and using methods.

• In Java, a language designed for OOP, there is no function
(all function must be constructed as a method of an object).

• Opposite paradigm to OOP is called functional
programming (FP).

More Related Content

PDF
Learning jQuery in 30 minutes
Simon Willison
 
PDF
jQuery - Chapter 3 - Effects
WebStackAcademy
 
PDF
Documenting your REST API with Swagger - JOIN 2014
JWORKS powered by Ordina
 
PPTX
REST API Design & Development
Ashok Pundit
 
PPTX
Python variables and data types.pptx
AkshayAggarwal79
 
PDF
JavaScript - Chapter 15 - Debugging Techniques
WebStackAcademy
 
PDF
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
PPT
Android Training
Tbldevelopment
 
Learning jQuery in 30 minutes
Simon Willison
 
jQuery - Chapter 3 - Effects
WebStackAcademy
 
Documenting your REST API with Swagger - JOIN 2014
JWORKS powered by Ordina
 
REST API Design & Development
Ashok Pundit
 
Python variables and data types.pptx
AkshayAggarwal79
 
JavaScript - Chapter 15 - Debugging Techniques
WebStackAcademy
 
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
Android Training
Tbldevelopment
 

What's hot (20)

PPT
Ajax Ppt 1
JayaPrakash.m
 
PPTX
jQuery
Jay Poojara
 
PDF
Wroclaw GraphQL - GraphQL in Java
MarcinStachniuk
 
PPTX
Angular
LearningTech
 
PDF
An introduction to MongoDB
Universidade de São Paulo
 
PPT
JavaScript JQUERY AJAX
Makarand Bhatambarekar
 
PPTX
Introduction to java 8 stream api
Vladislav sidlyarevich
 
PPT
JavaScript Arrays
Reem Alattas
 
PDF
Rest api with Python
Santosh Ghimire
 
PPTX
Android jetpack compose | Declarative UI
Ajinkya Saswade
 
PPTX
Object Oriented Programming In JavaScript
Forziatech
 
PPTX
Ajax and Jquery
People Strategists
 
PPT
JavaScript & Dom Manipulation
Mohammed Arif
 
PPTX
Mongo DB Presentation
Jaya Naresh Kovela
 
PPTX
Java servlets
yuvarani p
 
PDF
Introduction to Pandas and Time Series Analysis [PyCon DE]
Alexander Hendorf
 
PPSX
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
 
PPTX
Introduction to angular with a simple but complete project
Jadson Santos
 
PDF
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Ajax Ppt 1
JayaPrakash.m
 
jQuery
Jay Poojara
 
Wroclaw GraphQL - GraphQL in Java
MarcinStachniuk
 
Angular
LearningTech
 
An introduction to MongoDB
Universidade de São Paulo
 
JavaScript JQUERY AJAX
Makarand Bhatambarekar
 
Introduction to java 8 stream api
Vladislav sidlyarevich
 
JavaScript Arrays
Reem Alattas
 
Rest api with Python
Santosh Ghimire
 
Android jetpack compose | Declarative UI
Ajinkya Saswade
 
Object Oriented Programming In JavaScript
Forziatech
 
Ajax and Jquery
People Strategists
 
JavaScript & Dom Manipulation
Mohammed Arif
 
Mongo DB Presentation
Jaya Naresh Kovela
 
Java servlets
yuvarani p
 
Introduction to Pandas and Time Series Analysis [PyCon DE]
Alexander Hendorf
 
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
 
Introduction to angular with a simple but complete project
Jadson Santos
 
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 
Ad

Similar to Intro to JavaScript - Week 4: Object and Array (20)

PDF
3.1 javascript objects_DOM
Jalpesh Vasa
 
PPTX
Introduction to JcjfjfjfkuutyuyrsdterdfbvAVA.pptx
patilrohini0224
 
PPTX
JavaScript.pptx
pramod599939
 
PDF
Mastering The Collections in JavaScript [Free Meetup]
Haim Michael
 
PPTX
2CPP13 - Operator Overloading
Michael Heron
 
PPTX
Javascript
Tarek Raihan
 
PPTX
Introduction to JavaScript
Rangana Sampath
 
PPT
02._Object-Oriented_Programming_Concepts.ppt
Yonas D. Ebren
 
PDF
React-Native Lecture 11: In App Storage
Kobkrit Viriyayudhakorn
 
PPT
00-rewfwffwfwfwewfwwfwffeffvyu8ikview.ppt
jotola6956
 
PPT
00 OOP Introduction to Java Lecture Notes.ppt
Ijaduola Ilerioluwa
 
PPT
00-review.ppt
MiltonMolla1
 
PPT
Java
Prabhat gangwar
 
PDF
Python Programming and GIS
John Reiser
 
PPTX
Awesomeness of JavaScript…almost
Quinton Sheppard
 
PPT
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
PPT
standard template library(STL) in C++
•sreejith •sree
 
PDF
Java Script
Sarvan15
 
PPT
Java Script
Sarvan15
 
PPT
JavaScript ppt for introduction of javascripta
nehatanveer5765
 
3.1 javascript objects_DOM
Jalpesh Vasa
 
Introduction to JcjfjfjfkuutyuyrsdterdfbvAVA.pptx
patilrohini0224
 
JavaScript.pptx
pramod599939
 
Mastering The Collections in JavaScript [Free Meetup]
Haim Michael
 
2CPP13 - Operator Overloading
Michael Heron
 
Javascript
Tarek Raihan
 
Introduction to JavaScript
Rangana Sampath
 
02._Object-Oriented_Programming_Concepts.ppt
Yonas D. Ebren
 
React-Native Lecture 11: In App Storage
Kobkrit Viriyayudhakorn
 
00-rewfwffwfwfwewfwwfwffeffvyu8ikview.ppt
jotola6956
 
00 OOP Introduction to Java Lecture Notes.ppt
Ijaduola Ilerioluwa
 
00-review.ppt
MiltonMolla1
 
Python Programming and GIS
John Reiser
 
Awesomeness of JavaScript…almost
Quinton Sheppard
 
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
standard template library(STL) in C++
•sreejith •sree
 
Java Script
Sarvan15
 
Java Script
Sarvan15
 
JavaScript ppt for introduction of javascripta
nehatanveer5765
 
Ad

Recently uploaded (20)

PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PPTX
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Doc9.....................................
SofiaCollazos
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 

Intro to JavaScript - Week 4: Object and Array

  • 1. Introduction to Programming with JavaScript Week 4: Object, Array Jeongbae Oh YCC JavaScript Seminar 2017.10.30
  • 2. Object and Array • Since primitive data types cannot be changed ("immutable"), a more complicated form of data needs something else to be stored as information. • Object (객체) and array (배열) are most frequently used form of data structure in JavaScript. • Object and array allows for complex manipulation and operation of data.
  • 3. Object • Almost all values that is not a primitive type or an operator is an object. • Object consists of property and method.
  • 4. Object • Properties are "status" or "characteristics" of an object. • Properties are composed of key-value pair, • Methods are the "actions" that an object takes. • Example: car (object), color (property), accelerate (method)
  • 5. Object • var name = { [key: value] }; or 
 var name = new Object(); • Keys and values are optional (i.e. an empty object is allowed). • But a key must have its value.
  • 6. Property • Key has to be unique (i.e. no repeating keys). • Key can be a string or a number.
 ("" is not used for keys) • Value does not have to be unique. • Value can hold almost any data type.
 (Number, string, boolean, another object, function*, etc.)
  • 7. Property • Property can be accessed by: object.key or object[key]; • If the property's key is a number, the latter must be used. • Property can be created/changed similarly to assigning a value to a variable. • object.newKey = "newValue";
  • 8. Method • A property whose value is a function is called a method. • Since it's a function, it has to include () at the end when calling.
  • 9. Array Object • Array is a special type of object that is one-dimensional list. • Items in an array is called an element. • Array does not use key-value pairs.
  • 10. Creating Array • Empty • var arrayName = []; or 
 var arrayName = new Array(); • With elements • var arrayName = [1, 2, 3]; • Elements can be of almost any data type.
  • 11. Indexing • As array does not have keys, its elements have to be accessed by using index (position of element within array).
 arrayName[index]; • In programming, index starts with 0, instead of 1.
  • 12. Array Properties & Methods • arrayName.length; • arrayName.indexOf(value);
 → Returns index of the value • arrayName.push(element); 
 → Returns index of added element • arrayName.pop();
 → Returns removed value

  • 13. String Object • string.includes() • string.startsWith() • string.endsWith() • string.split()
  • 14. String Object • string.slice() or
 string.substring() • string.toLowerCase() • string.toUpperCase() • string.trim() • string.length (property)
  • 15. Number Object • Number.isFinite() • Number.isInteger() • Number.isNaN() • Number.parseFloat() • Number.parseInt() • number.toExponential()* • number.toString()*
  • 16. Date Object • Allows calculation of date/time • Time is assigned when called/ initialized • Date object's methods allow formatting date within string. • getMonth() starts with 0, not 1
  • 17. UNIX Time • JavaScript uses UNIX time, which means the beginning (time 0) is defined as 1970-01-01 00:00:00.000 (UTC). • All times are calculated in relation to the time 0. • 86399999: 1970-01-01 23:59:59.999 (UTC) • 1509346681342: 2017-10-30 06:58:01.342 (UTC) • This number is called a timestamp. • Browser automatically formats time in the local/server time, but calculations must be done based on UTC.
  • 18. Date Object • Dates can be created/calculated using UNIX time. • Dates can also be created using time string.
  • 19. JSON • JavaScript Object Notation • Constructed the same way as an object • Used to transfer data in various settings (web, app, database, API server, etc.)
  • 20. JSON for API • Example: Foursquare API • Developer sign up: https://ko.foursquare.com/ developers/apps • Developer documentation: https:// developer.foursquare.com/docs
  • 21. JSON for API https://api.foursquare.com/v2/venues/ search?v=20171030&m=foursquare&
 client_id=[CLIENT_ID]&client_secret=[CLIE NT_SECRET]&ll=[COORDINATES] Client API Server {"meta":{"code": 200,"requestId":"59fbf3496a607142ba7a7d f4"},"response":{"venues": [{"id":"5340142111d247f646bce6f6","name ":"4x4","location":{"lat": 37.557804107666016,"lng": 126.93865203857422,"labeledLatLngs": [{"label":"display","lat": 37.557804107666016,"lng": 126.93865203857422}], ... • Searching for venues around a specific coordinate
  • 22. JSON for API • Response (use JSON formatter Chrome extension)
  • 23. JSON for API • Response (JSON formatter extension used)
  • 24. JSON for API • Using loops to process raw data
  • 25. JSON for API • Refining data to find insights
  • 26. Object-Oriented Programming (OOP) • JavaScript can also be used as an OOP language such as Java. (But no real connection to Java, of course.) • OOP is a programming paradigm which centers around making objects and using methods. • In Java, a language designed for OOP, there is no function (all function must be constructed as a method of an object). • Opposite paradigm to OOP is called functional programming (FP).