json format javascript code example
Example 1: format JSON code javascript
console.log(JSON.stringify({ alpha: 'A', beta: 'B' }, null, '\t'));
// Result:
// '{
// "alpha": A,
// "beta": B
// }'
Example 2: create a json object in javascript
var employee = {
"firstName": firstName,
"lastName": lastName
}
Example 3: create a javascript json object
const student = {
name: "bob",
age: 7,
grade: 6
}