Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                // creating an object
var anObject = {
  name: "this is an object",
  "object number": 2,
  more_strings: 3,
  "object array": ["one", "two"]
};
// is this an object?
console.log("anObject is a " + typeof anObject);
console.log("anObject length " + anObject.length); // objects dont have length

var anArray = [["i am an array"], ["i am an array"]];
console.log("anArray is a " + typeof anArray);
// this will also show that this is an object

console.log("anArray length " + anArray.length); // arrays do have length but are also type of object

// accessing the object values
var object_name = anObject.name;
console.log(object_name);

var object_number = anObject["object number"]; // to access the object with the string as a name you need to use the brackets similar to an array.
console.log(object_number);

// access it via a dynamic variable name
var obj_var_name = "more_strings";
var more_strings_val = anObject[obj_var_name];
console.log("more_strings_val: " + more_strings_val);

// update objects
anObject["object number"] = 6; // you can use brackets and quotes or
anObject.name = "this is still an object"; // use the . if their is no spaces.

// add new object property
anObject["new property"] = "new property value"; // or
anObject.new_property = "another value";
console.log(anObject);

// delete an object property
delete anObject["new property"];
delete anObject.new_property;
console.log(anObject);

// check if a property exists
console.log(anObject.hasOwnProperty("more_strings"));
console.log(anObject.hasOwnProperty("no_more_strings"));

// function to check if a property exists
function checkObjExists(checkProp) {
  // Your Code Here
  if (anObject.hasOwnProperty(checkProp)) {
    return anObject[checkProp];
  } else {
    return "Not Found";
  }
}
console.log(checkObjExists("more_strings"));
console.log(checkObjExists("no_more_strings"));

// complex objects -- create the main structure then add multiple with a comma
var aComplexObject = {
  "object title": {
    "nested one": {
      val1: "value",
      val2: "value 2"
    },
    "nested two": {
      val1: "value two!",
      val2: "value 2"
    }
  }
};
console.log(aComplexObject);

// see if we can access to read and then update it. you can use a mixture of . and "" to access the properties.
console.log(aComplexObject["object title"]["nested two"].val1);
aComplexObject["object title"]["nested two"].val1 = "value two!!!";
console.log(aComplexObject["object title"]["nested two"].val1);


              
            
!
999px

Console