repl.it
@MIhm7904/

SampleSet6

Nodejs

Sample Set 6: Objects

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const person = {"firstName" : "Jean-Luc", "lastName" : "Picard"}

console.log(person)
//will return {firstName: 'Jean-Luc', lastName 'Picard'}
console.log(person["firstName"])
//will return Jean-Luc
console.log(person["lastName"])
//will return Picard
person["rank"] = "Captain"
console.log(person)
//will return {firstName: 'Jean-Luc', lastName 'Picard', rank: 'Captain'}
person["firstName"] = "Locotus"
console.log(person)
//will return {firstName: 'Locotus', lastName 'Picard', rank: 'Captain'}