How to create and access JSON object in JavaScript

3 Answers

0 votes
const json = {"name":"Tom","age":56,"profession":"Developer"};

const name = json.name;
const age = json.age;

console.log(name);
console.log(age);


   
/*
run:
 
Tom
56
 
*/

 



answered Mar 3, 2019 by avibootz
edited Mar 21, 2020 by avibootz
0 votes
const json = {"name":"Tom","age":56,"profession":"Developer"};

console.log(json.name);
console.log(json.age);
console.log(json.profession);


   
/*
run:
 
Tom
56
Developer
 
*/

 



answered Mar 3, 2019 by avibootz
edited Mar 21, 2020 by avibootz
0 votes
const json = {"name":"Leo","age":45,"profession":"Developer"};

console.log(json['name']);
console.log(json['age']);
console.log(json['profession']);


   
/*
run:
 
Leo
45
Developer
 
*/

 



answered Mar 21, 2020 by avibootz

Related questions

...