Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                ////////////////////////////
// Javascript and JSON
//
//     JSON is the standard of exchanging information
//     with remote servers / http servers.
//
//     Mechanism for transforming complex objects into
//     human readable string representations.
//
//     It was made to replace XML as the format for exchanging
//     data between servers (cleint / remote HTTP server.)
//
//     V.Popular - AJAX communications with http servers
//
//     Used for storing objects in LocalStorage. If we want to save
//     a javascript object, we will have to turn it into JSON, then save
//     it. When we read from the datastore, we retrieve the JSON,
//     and turn it back into an object. Note: LocalStorage is
//     the space reserved by the browser to be used as a small db for
//     the application. 
//
//     Schematic of Function:
// 
//     Storing Object in LocalStorage:
//        Object -> JSONstring -> Local Storage
//
//     Retrieving Object from LocalStorage:
//        LocalStorage -> JSONstring -> Object
//
//     1. object to JSON -> JSON.stringify(obj)
//     2. JSON to object -> JSON.parse(jsonString)


// ex 1 - simple int -> will return string int
var x = 3;
var JsonString1 = JSON.stringify(x);
console.log(JsonString1);
var JsonStringtoObj = JSON.parse(JsonString1);
console.log(JsonStringtoObj);

// ex 2 - with simple array 
var x = [ 1, "2", "The", 3];
var JsonString1 = JSON.stringify(x);
console.log(JsonString1);
var JsonStringtoObj = JSON.parse(JsonString1);
console.log(JsonStringtoObj);





// ex 2 - with simple object, dict 
var x = { 
  x:12, 
  y:30
}
var JsonString1 = JSON.stringify(x);
console.log(JsonString1);
var JsonStringtoObj = JSON.parse(JsonString1);
console.log(JsonStringtoObj);




// ex 2 - with simple object, dict 
var x = { 
  x : 12, 
  y : 30,
  z : [ 1, 2, 3 ]
}
var JsonString1 = JSON.stringify(x);
console.log(JsonString1);
var JsonStringtoObj = JSON.parse(JsonString1);
console.log(JsonStringtoObj);


// ex 2 - with simple object, dict 
var x = {name:'Metallica',
    albums:[
        {name:"Master of Puppets", year:1986},
        {name:"Black Album", year:1991}
    ]
  };
var JsonString1 = JSON.stringify(x);
console.log(JsonString1);
var JsonStringtoObj = JSON.parse(JsonString1);
console.log(JsonStringtoObj);


              
            
!
999px

Console