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
Introduction to CSS
PDF
Style and Selector
PPTX
An Introduction to the DOM
PPTX
Html forms
PDF
Dynamic CSS: Transforms, Transitions, and Animation Basics
PDF
Nodejs
PPT
Eye catching HTML BASICS tips: Learn easily
KEY
HTML presentation for beginners
Introduction to CSS
Style and Selector
An Introduction to the DOM
Html forms
Dynamic CSS: Transforms, Transitions, and Animation Basics
Nodejs
Eye catching HTML BASICS tips: Learn easily
HTML presentation for beginners

What's hot (20)

PPTX
Dom(document object model)
PDF
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
PPTX
CSS3 2D/3D transform
PPTX
HTML Semantic Tags
PPTX
XML Document Object Model (DOM)
PPT
Introduction to HTML5
PDF
Introduction to HTML5
PDF
Client Side MVC & Angular
PPT
Introduction to Javascript
PPTX
Block and inline elements in HTML
PDF
ES6 presentation
PDF
Lab#5 style and selector
PPT
Advanced Javascript
PPTX
Html training slide
PPTX
Good/Bad Web Design
PPTX
Html5 semantics
PPTX
PPTX
Css Basics
PDF
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
PPTX
CSS Animations & Transitions
Dom(document object model)
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
CSS3 2D/3D transform
HTML Semantic Tags
XML Document Object Model (DOM)
Introduction to HTML5
Introduction to HTML5
Client Side MVC & Angular
Introduction to Javascript
Block and inline elements in HTML
ES6 presentation
Lab#5 style and selector
Advanced Javascript
Html training slide
Good/Bad Web Design
Html5 semantics
Css Basics
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
CSS Animations & Transitions
Ad

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

PPTX
Cordova training : Day 4 - Advanced Javascript
PPTX
Javascript Objects and Functions
PPT
Js objects
PPTX
Javascript Objects and Functions
PPTX
13_User_Defined_Objects.pptx objects in javascript
PPTX
The JavaScript Programming Language
KEY
PPTX
1-JAVA SCRIPT. servere-side applications vs client side applications
PDF
Quiz JavaScript Objects Learn more about JavaScript
PDF
PDF
JAVASCRIPT OBJECTS.pdf
PPTX
Java script
PPT
Ajax and JavaScript Bootcamp
PPTX
Object oriented javascript
PDF
Introduction to web programming for java and c# programmers by @drpicox
PDF
Java script summary
PPTX
Learn java script
DOCX
Java script basics
PDF
JavaScript and jQuery - Web Technologies (1019888BNR)
PDF
Javascript
Cordova training : Day 4 - Advanced Javascript
Javascript Objects and Functions
Js objects
Javascript Objects and Functions
13_User_Defined_Objects.pptx objects in javascript
The JavaScript Programming Language
1-JAVA SCRIPT. servere-side applications vs client side applications
Quiz JavaScript Objects Learn more about JavaScript
JAVASCRIPT OBJECTS.pdf
Java script
Ajax and JavaScript Bootcamp
Object oriented javascript
Introduction to web programming for java and c# programmers by @drpicox
Java script summary
Learn java script
Java script basics
JavaScript and jQuery - Web Technologies (1019888BNR)
Javascript
Ad

Recently uploaded (20)

PDF
Electrocardiogram sequences data analytics and classification using unsupervi...
PDF
Auditboard EB SOX Playbook 2023 edition.
PPTX
Internet of Everything -Basic concepts details
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PDF
Human Computer Interaction Miterm Lesson
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
PPTX
Training Program for knowledge in solar cell and solar industry
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PPTX
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PDF
Ensemble model-based arrhythmia classification with local interpretable model...
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
Electrocardiogram sequences data analytics and classification using unsupervi...
Auditboard EB SOX Playbook 2023 edition.
Internet of Everything -Basic concepts details
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
Human Computer Interaction Miterm Lesson
A symptom-driven medical diagnosis support model based on machine learning te...
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
Training Program for knowledge in solar cell and solar industry
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
SGT Report The Beast Plan and Cyberphysical Systems of Control
Ensemble model-based arrhythmia classification with local interpretable model...
Build Real-Time ML Apps with Python, Feast & NoSQL
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
Early detection and classification of bone marrow changes in lumbar vertebrae...
Data Virtualization in Action: Scaling APIs and Apps with FME

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).