Horje
JSON stringify method - the optional parameters Code Example
JSON stringify method - the optional parameters
//https://www.youtube.com/watch?v=0k4NwimfszA
// json-stringify.js
// Lesser known features when using JSON.stringify()
//Video Tutorial :https://youtu.be/0k4NwimfszA

let obj = {name: "Walter", 
           last: "Sobchak",
           age: 50, 
           angry: true, 
           bestscore: 200, 
           armed: true};
let log = console.log;
let str;

str = JSON.stringify(obj);
log('1', str);

str = JSON.stringify(obj, ['age', 'angry', 'last']);
log('\n2', str);

function replace(key, val){
    if(typeof val === 'number'){
        return undefined;
    }else{
       return val; 
    }
}
str = JSON.stringify(obj, replace);
log('\n3', str);

str = JSON.stringify(obj, null, 4);
log('\n4', str);

str = JSON.stringify(obj, null, '\tX\tX\tX\t');
log('\n5', str);




Javascript

Related
adding to an array without mutating the original array Code Example adding to an array without mutating the original array Code Example
router.push next js Code Example router.push next js Code Example
javascript icon Code Example javascript icon Code Example
Node-Red: 2Outputs Code Example Node-Red: 2Outputs Code Example
how to write a program that alerts the first 3 letters of the current day in javascript Code Example how to write a program that alerts the first 3 letters of the current day in javascript Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8