Fluxograma
Object data type overview
Conteúdo do fluxograma
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.
Informações
- Descrição
- Junior Certificate Web Developing Fluxograma sobre Object data type overview, criado por Kostas Diakogiannis em 12-10-2018.
- Criado por
- Kostas Diakogiannis
- Visualizações
- 4
- Histórico
-
- Criado por Kostas Diakogiannis · 12 out 2018
- Copiado por Kostas Diakogiannis · 12 out 2018
- Copiado por Kostas Diakogiannis · 12 out 2018
- Avaliação