-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
31 lines (22 loc) · 931 Bytes
/
example.js
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
function describe_object_array_manipulation_from_obj_values() {
const obj_old = { uname: 'frank', value1: 9, value2: 12 }
let obj_new = {}
// check if uname key exists in object.
console.log(!('uname' in obj_new)) // false
// create an empty array of 2 for the values to eventually land.
obj_new['uname'] = new Array(2)
// now uname key should exist
console.log(!('uname' in obj_new)) // true
}
describe_object_array_manipulation_from_obj_values()
function describe_object_array_manipulation() {
const obj_old = { uname: 'frank', value1: 9, value2: 12 }
let obj_new = {}
// check if uname key exists in object.
console.log(!(obj_old.uname in obj_new)) // false
// create an empty array of 2 for the values to eventually land.
obj_new[obj_old.uname] = new Array(2)
// now uname key should exist
console.log(!(obj_old.uname in obj_new)) // true
}
describe_object_array_manipulation()