Intro to JavaScript - Week 4: Object and Array

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).
1 von 26

Recomendados

2CPP13 - Operator Overloading von
2CPP13 - Operator Overloading2CPP13 - Operator Overloading
2CPP13 - Operator OverloadingMichael Heron
1K views21 Folien
Java 103 intro to java data structures von
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structuresagorolabs
3.3K views65 Folien
Collection advance von
Collection advanceCollection advance
Collection advanceAakash Jain
54 views37 Folien
Chapter 6.3 von
Chapter 6.3Chapter 6.3
Chapter 6.3sotlsoc
250 views12 Folien
Json - ideal for data interchange von
Json - ideal for data interchangeJson - ideal for data interchange
Json - ideal for data interchangeChristoph Santschi
624 views69 Folien
Skillwise - Enhancing dotnet app von
Skillwise - Enhancing dotnet appSkillwise - Enhancing dotnet app
Skillwise - Enhancing dotnet appSkillwise Group
391 views80 Folien

Más contenido relacionado

Was ist angesagt?

Distributed computing with spark von
Distributed computing with sparkDistributed computing with spark
Distributed computing with sparkJavier Santos Paniego
2.2K views57 Folien
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build) von
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)Jannat Ruma
148 views32 Folien
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build) von
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Jannat Ruma
53 views8 Folien
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build) von
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Jannat Ruma
120 views11 Folien
Spark: Taming Big Data von
Spark: Taming Big DataSpark: Taming Big Data
Spark: Taming Big DataLeonardo Gamas
702 views60 Folien
Java class 5 von
Java class 5Java class 5
Java class 5Edureka!
2K views35 Folien

Was ist angesagt?(20)

C# Basic - Lec1 (Workshop on C# Programming: Learn to Build) von Jannat Ruma
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
Jannat Ruma148 views
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build) von Jannat Ruma
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Jannat Ruma53 views
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build) von Jannat Ruma
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Jannat Ruma120 views
Java class 5 von Edureka!
Java class 5Java class 5
Java class 5
Edureka!2K views
Qtp training session IV von Aisha Mazhar
Qtp training session IVQtp training session IV
Qtp training session IV
Aisha Mazhar296 views
JavaScript / Web Engineering / Web Development / html + css + js/presentation von M Sajid R
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentation
M Sajid R260 views
Java Tutorial Lab 8 von Berk Soysal
Java Tutorial Lab 8Java Tutorial Lab 8
Java Tutorial Lab 8
Berk Soysal2.9K views
Collections - Maps von Hitesh-Java
Collections - Maps Collections - Maps
Collections - Maps
Hitesh-Java1.4K views
Collections - Lists, Sets von Hitesh-Java
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
Hitesh-Java606 views
Utilizing the open ntf domino api von Oliver Busse
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
Oliver Busse782 views
Java Collections von parag
Java CollectionsJava Collections
Java Collections
parag8.6K views
Aj unit2 notesjavadatastructures von Arthik Daniel
Aj unit2 notesjavadatastructuresAj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructures
Arthik Daniel413 views
L11 array list von teach4uin
L11 array listL11 array list
L11 array list
teach4uin3K views

Similar a Intro to JavaScript - Week 4: Object and Array

3.1 javascript objects_DOM von
3.1 javascript objects_DOM3.1 javascript objects_DOM
3.1 javascript objects_DOMJalpesh Vasa
349 views63 Folien
JavaScript.pptx von
JavaScript.pptxJavaScript.pptx
JavaScript.pptxpramod599939
3 views13 Folien
Javascript von
JavascriptJavascript
JavascriptTarek Raihan
31 views20 Folien
Introduction to JavaScript von
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptRangana Sampath
484 views21 Folien
02._Object-Oriented_Programming_Concepts.ppt von
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.pptYonas D. Ebren
2 views50 Folien
React-Native Lecture 11: In App Storage von
React-Native Lecture 11: In App StorageReact-Native Lecture 11: In App Storage
React-Native Lecture 11: In App StorageKobkrit Viriyayudhakorn
16K views50 Folien

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

3.1 javascript objects_DOM von Jalpesh Vasa
3.1 javascript objects_DOM3.1 javascript objects_DOM
3.1 javascript objects_DOM
Jalpesh Vasa349 views
02._Object-Oriented_Programming_Concepts.ppt von Yonas D. Ebren
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
Yonas D. Ebren2 views
Python Programming and GIS von John Reiser
Python Programming and GISPython Programming and GIS
Python Programming and GIS
John Reiser5.1K views
Java Script von Sarvan15
Java ScriptJava Script
Java Script
Sarvan1512 views
Fii Practic Frontend - BeeNear - laborator3 von BeeNear
Fii Practic Frontend - BeeNear - laborator3Fii Practic Frontend - BeeNear - laborator3
Fii Practic Frontend - BeeNear - laborator3
BeeNear547 views
Javascript arrays von Hassan Dar
Javascript arraysJavascript arrays
Javascript arrays
Hassan Dar6.5K views
Programming in java basics von LovelitJose
Programming in java  basicsProgramming in java  basics
Programming in java basics
LovelitJose90 views
Core java complete ppt(note) von arvind pandey
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey5.8K views
Query String Parameters & Methods in NodeJS.pptx von HemaSenthil5
Query String Parameters & Methods in NodeJS.pptxQuery String Parameters & Methods in NodeJS.pptx
Query String Parameters & Methods in NodeJS.pptx
HemaSenthil53 views
Concept of Object-Oriented in C++ von Abdullah Jan
Concept of Object-Oriented in C++Concept of Object-Oriented in C++
Concept of Object-Oriented in C++
Abdullah Jan545 views

Último

Network Source of Truth and Infrastructure as Code revisited von
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisitedNetwork Automation Forum
25 views45 Folien
Vertical User Stories von
Vertical User StoriesVertical User Stories
Vertical User StoriesMoisés Armani Ramírez
12 views16 Folien
Business Analyst Series 2023 - Week 3 Session 5 von
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5DianaGray10
237 views20 Folien
PharoJS - Zürich Smalltalk Group Meetup November 2023 von
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
126 views17 Folien
Design Driven Network Assurance von
Design Driven Network AssuranceDesign Driven Network Assurance
Design Driven Network AssuranceNetwork Automation Forum
15 views42 Folien
Uni Systems for Power Platform.pptx von
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
55 views21 Folien

Último(20)

Business Analyst Series 2023 - Week 3 Session 5 von DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10237 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 von Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi126 views
Empathic Computing: Delivering the Potential of the Metaverse von Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst476 views
Piloting & Scaling Successfully With Microsoft Viva von Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive von Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Case Study Copenhagen Energy and Business Central.pdf von Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
Attacking IoT Devices from a Web Perspective - Linux Day von Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... von Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker33 views

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