forked from HackYourFuture-CPH/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharrayOfObjects.js
More file actions
37 lines (28 loc) · 824 Bytes
/
arrayOfObjects.js
File metadata and controls
37 lines (28 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
let employees = [];
employees.push({ name: 'John', forename: 'L', city: 'Copenhagen'});
employees.push({ name: 'John', forename: 'M', city: 'Malmo'});
employees.push({ name: 'John', forename: 'X', city: 'Oslo'});
// console.log(employees);
for (let i =0; i < employees.length; i++) {
console.log(employees[i].city)
}
function getPerson(firstname, lastname) {
const person = {
firstname: firstname,
lastname: lastname
};
return person;
}
console.log(getPerson('Alicia', 'Gonzalez'))
// Empty object
let emptyObject = {};
// function returning empty object
function stupidFunction(){
return {};
}
emptyObject = stupidFunction();
// not so stupid anymore:
emptyObject.name = 'Alicia'
let arrayOfArray = [['Copenhagen','John'],['Malmo','Peter']];
let outTwoDimArray = [[],[]];
console.log( outTwoDimArray[1] );