Pen Settings



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


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


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.


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.


                <p><b>Be sure to open to console to view the results.</b></p>
<br />
<br />
<hr />
<p style="text-align:left;">If you find this demo useful, please consider <a href="" target="_blank">donating $1 dollar</a> (secure PayPal link) for a coffee or purchasing one of my songs from <a href="" target="_blank"></a> or <a href="" target="_blank"></a> for only 0.99 cents each.</p>
<p style="text-align:left;">Rob uses and recommends <a href="" target="_blank">MochaHost</a>, which provides Web Hosting for as low as $1.95 per month, as well as unlimited emails and disk space!</p>




                "use strict";

function DuckTypeError() {
    var temp = TypeError.apply(this, arguments); = = 'DuckTypeError';
    this.message = temp.message;
    if(Object.defineProperty) {
        // getter for better optimization
        /*this.stack = */Object.defineProperty(this, 'stack', { 
            get: function() {
                return temp.stack
            configurable: true // so you can change it if you want
    } else {
        this.stack = temp.stack
//inherit prototype using ECMAScript 5 (IE 9+)
DuckTypeError.prototype = Object.create(TypeError.prototype, {
    constructor: {
        value: DuckTypeError,
        writable: true,
        configurable: true

function Infiniti(model) { 
    this.model = model;
Infiniti.prototype.accelerate = function() {
    console.log(this.model + ": Going from 0 to 60mph really fast!");

function Honda(model) {
    this.model = model;
Honda.prototype.accelerate = function() {
    console.log(this.model + ": Going from 0 to 60mph at a moderate speed.");

function Hyundai(model) {
    this.model = model;
Hyundai.prototype.accelerate = function() {
    console.log(this.model + ": Going from 0 to 60mph at a crawl.");

function Couch(type) {
    this.type = type;

function race(car) {
    //Dynamically invoke accelerate() method 
    //of whatever car was passed in.
    if (car.accelerate) 
      throw new DuckTypeError("Hey, you're not a car!");

//Let's race some cars!
var cars = [
  new Infiniti("G37"),
  new Honda("Civic"),
  new Hyundai("Accent")
for (var i in cars) { 

//try to race a sofa!?
race( new Couch("Sofa") );