Flowchart
Object data type overview
Flowchart content
JavaScript Objects Type
Objects Data Type
Objects help us to store multiple pieces of information in one place by defining key value pairs inside them. The keys work as placeholders, while the values can be any data type.
let newUser = {firstName: 'Kostas', lastName: 'Diakogiannis', age: 30, nickName: 'Jake', profession: 'Data Scientist'};
Or you can create an object template by using the new constructor as shown here.
In order to access a property of an object we use the keys: There are 2 ways as shown below, both do the same thing. Select the firstName property from the newUser object.
console.log(newUser.firstName)
OR
console.log(newUser['firstName'])
Properties can be also functions, These functions when called belong to the object and only to the object and they can changes object's properties. These are called Methods.
Properties and methods can also be sharable through many objects. The object that all these objects inherit from is called a parent Object. example:
let Human = {kind: 'Human' , legs: 2, ears: 2, hands: 2, eyes: 2};
With the setPrototypeOf property we can make the human properties shared to the newUser and to whatever object calls this setPrototypeOf function.
Object.setPrototypeOf(newUser, Human);
console.log(newUser.legs) // Prints 2
Objects are iterable, that means you can loop through each object properties with a for - in loop, by setting a standard variable that each time holds the key for every iteration.
The for in loop explained here!!
Additionally you can reference to an object property from inside the object by using the 'this' keyword.
Information
- Description
- Junior Certificate Web Developing Flowchart on Object data type overview, created by Kostas Diakogiannis on 12/10/2018.
- Created by
- Kostas Diakogiannis
- Views
- 4
- History
-
- Created by Kostas Diakogiannis · Oct 12, 2018
- Copied by Kostas Diakogiannis · Oct 12, 2018
- Copied by Kostas Diakogiannis · Oct 12, 2018
- Rating