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

              
                <table>
	<thead><tr>
    <th>Test Name</th>
    <th>Total Count</th>
    <th>Own Property Count</th>
    <th>Matches Test</th>
    <th>Prototype Property Count</th>
    <th>Matches Test</th>
  </tr></thead>
  <tbody id="result"></tbody>
</table>
              
            
!

CSS

              
                th, td {
  border-right: 1px solid black;
  padding: 0.1em 0.25em;
}
              
            
!

JS

              
                var t1 = {a:1, b:2, c:3};
var $el = $('#result');

function Test() {};

Test.prototype = {
  test1: undefined,
  test2: function() {}
};

var test = new Test();

function fnCountProperties(o) {
  var iCountPrototype = 0;
  var iCountOwn = 0;
  var iTotal = 0;
  
  for (var prop in o) {
    if (o.hasOwnProperty(prop)) {
      iCountOwn += 1;
    } else {
      iCountPrototype += 1;
    }
  }
  
  iTotal = new Number(iCountOwn + iCountPrototype);
  iTotal.countOwn = iCountOwn;
  iTotal.countPrototype = iCountPrototype;
  
  return iTotal;
}

function fnAssertResults(sName, o, i, j) {
  var iCount = fnCountProperties(o),
      sOwnMatches = i === iCount.countOwn,
      sPrototypeMatches = j === iCount.countPrototype;
  console.log(iCount);
  $('<tr><td>' + sName + '</td><td>' + iCount + '</td><td>' + iCount.countOwn + '</td><td>' + sOwnMatches + '</td><td>' + iCount.countPrototype + '</td><td>' + sPrototypeMatches + '</td></tr>').appendTo($el);
}

fnAssertResults('{}', {}, 0, 0);
fnAssertResults("{a:1, b:2, c:3}", t1, 3, 0);
fnAssertResults('Test class', test, 0, 2);
test.test3 = 1;
fnAssertResults('Test - add own property', test, 1, 2);

// Overriding a prototype variable changes it to be on the object itself.
test.test1 = 1;
fnAssertResults('Test - override prototype variable', test, 2, 1);

Test.prototype.test4 = 2;
fnAssertResults('Add to Test.prototype', test, 2, 2);
fnAssertResults("window (will fail)", window, 0, 0);
              
            
!
999px

Console