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 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

              
                body(ng-app="myApp" ng-controller="AppCtrl as app")
  p Array Length: {{ app.arr.length }} {{ app.errorMessage }}
  button(ng-click="app.makeNullsWithHoles()") Make nulls in array with holes
  button(ng-click="app.makeMap()") Use object as map instead of array
  button(ng-click="app.max5Properties()") Use array, but have a maximum of 5 properties at any given time
  button(ng-click="app.arr = []; app.obj = {}") Clear
  
  // -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=-
  // Page Footer
  small.footer(ng-non-bindable)
    div(app="footerApp" ng-controller="FooterCtrl as footer" ng-cloak)
      span.left
        b Angular v{{footer.version.full}}
        |  ({{footer.version.codeName}})
      span.right
        != '&copy; '
        a(ng-href="{{footer.author.url}}" target="_blank")
          | {{footer.author.name}}

              
            
!

CSS

              
                

/* -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=- */
/* Page Footer */
body { padding-bottom: 2em; }
.footer { background-color: White; border-top: 1px solid rgba(100, 100, 100, 0.33); bottom: 0; display: block; font-size: 0.75em; height: 1.5em; left: 0; margin: 0 5px; overflow: auto; padding: 5px; position: fixed; right: 0; }
.footer > div { display: flex; flex-direction: row; }
.footer .left { flex-grow: 2; text-align: left; }
.footer .right { flex-grow: 1; text-align: right; }
[ng-cloak] { display: none !important; }

              
            
!

JS

              
                console.clear();
window.CP.PenTimer.MAX_TIME_IN_LOOP_WO_EXIT = 60000;
(function () {'use strict';

angular.
  module('myApp', []).
  controller('AppCtrl', AppCtrl).
  directive('test', testDirective);

// Functions - Definitions
function AppCtrl() {
  this.arr = [];
  this.obj = {};
  this.errorMessage = "";
  this.makeNullsWithHoles = () => {
    for (let i = 0; i < 1000000; ++i) {
      this.arr.push(null);
    }
    console.log("All nulls pushed to array.");
    for (let i = 0; i < 500000; ++i) {
      if ((i % 10000) === 0) {
        console.log("Deleting " + i + "/" + 500000 + "(" + (i / 500000)*100  + "%)");
      }
      delete this.arr[i];
    }
    console.log("All deleted.");
    if (!window['gc']) {
      this.errorMessage = 'If you run Chrome with --js-flags="--expose-gc", we can force a GC.';
    } else {
      window.gc();
    }
    console.log("GC complete.");
  };
  this.makeMap = () => {
    for (let i = 0; i < 1000000; ++i) {
      this.obj[i] = null;
    }
    console.log("Null additions to object complete.")
    for (let i = 0; i < 500000; ++i) {
      if ((i % 10000) === 0) {
        console.log("Deleting " + i + "/" + 500000 + "(" + (i / 500000)*100  + "%)");
      }
      delete this.obj[i];
    }
    if (!window['gc']) {
      this.errorMessage = 'If you run Chrome with --js-flags="--expose-gc", we can force a GC.';
    } else {
      window.gc();
    }
  };
  this.max5Properties = () => {
    for (let i = 0; i < 1000000; ++i) {
      this.arr.push(null);
      if (i > 4) {
        // Randomly delete one property to keep under 5 propertie large.
        let keys = Object.keys(this.arr);
        delete this.arr[keys[Math.floor(keys.length*Math.random())]];
      }
      if ((i % 10000) === 0) {
        console.log("Iteration " + i + "/" + 1000000 + "(" + (i / 1000000)*100  + "%)");
      }
    }
  }
}

function testDirective() {
  // DDO
  return {
    template: 'Hello, world!',
    scope: {},
    controller: TestCtrl,
    controllerAs: '$ctrl',
    bindToController: true
  };
  
  // Functions - Definitions
  function TestCtrl() {}
}

}());

/* -=-=-=-=- -=[IGNORE BELOW THIS LINE]=- -=-=-=-=- */
/* Page Footer */
(function () {'use strict';
var app = 'footerApp';
angular.module(app, []).controller('FooterCtrl', FooterCtrl);
angular.bootstrap(document.querySelector('[app="' + app + '"]'), [app]);
function FooterCtrl($window) {
  this.version = $window.angular.version;
  this.author = {name: 'GKalpak', url: '//github.com/gkalpak/'};
}
}());

              
            
!
999px

Console