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

              
                
<pre class="ts"><code class="ts">

class Polygon {
    name: string;
    height: number;
    width: number;

  constructor(height, width) {
    this.name = 'Polygon';
    this.height = height;
    this.width = width;
  }
  saySomething() {
    console.log(`Hi, I am a ${this.name} `+
                `with Height: ${this.height} and Width: ${this.width}`);
    // Note the use of a string Expression with backticks
  }
}

let poly = new Polygon(40, 20);
poly.saySomething();
// "Hi, I am a Polygon. with Height: 40 and Width: 20"


 class Square extends Polygon{
   constructor(height, width) {
    super(height, width);
    this.name = 'Square';
  }
 }

let squarely = new Square(20, 20);
squarely.saySomething();
//"Hi, I am a Square. with Height: 20 and Width: 20"

 class Hexagon extends Polygon{
   rapName: string; // new Argument
   constructor(height, width, rapName) {
    super(height, width); // The parents constructor arguments    
    this.name = 'Hexagon';
    this.rapName = rapName;
  }
   saySomething() {
     super.saySomething(); // calling a parent class method
     console.log( 'I like battle rapping in my free time...');
     console.log( `My Rapper name is ${this.rapName}, bring it !`);
     //and extending it...
    }
 }

let hexy = new Hexagon(40, 80, 'Ice Gon Kwazy');
// Notice the addition of a new argument
hexy.saySomething();
// "Hi, I am a Hexagon. with Height: 40 and Width: 80"
// "I like battle rapping in my free time !"
// "My Rapper name is Ice Gon Kwazy bring it !"

</code></pre>


              
            
!

CSS

              
                body{
  background-color: #888;
  padding: 10px;
}

code{
  font-size:15px;
  border-radius: 5px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.60);
  padding-left:20px !important;
}

pre.es5:before{
  content: "ES5: ";
}

pre.ts:before{
  content: "TypeScript: ";
}


pre.es6:before{
  content: "ES6: (Babel) ";
}

code.es6{
background-color: #222;
}
              
            
!

JS

              
                //Highlighter stuff ignore
hljs.initHighlightingOnLoad();
//Highlighter stuff ignore

class Polygon {
    name: string;
    height: number;
    width: number;

  constructor(height, width) {
    this.name = 'Polygon';
    this.height = height;
    this.width = width;
  }
  saySomething() {
    console.log(`Hi, I am a ${this.name} `+
                `with Height: ${this.height} and Width: ${this.width}`);
    // Note the use of a string Expression with backticks
  }
}

let poly = new Polygon(40, 20);
poly.saySomething();
// "Hi, I am a Polygon. with Height: 40 and Width: 20"


 class Square extends Polygon{
   constructor(height, width) {
    super(height, width);
    this.name = 'Square';
  }
 }

let squarely = new Square(20, 20);
squarely.saySomething();
//"Hi, I am a Square. with Height: 20 and Width: 20"

 class Hexagon extends Polygon{
   rapName: string; // new Argument
   constructor(height, width, rapName) {
    super(height, width);
    this.name = 'Hexagon';
    this.rapName = rapName;
  }
   saySomething() {
     super.saySomething(); // calling a parent class method
     console.log( 'I like battle rapping in my free time...');
     console.log( `My Rapper name is ${this.rapName}, bring it !`);
     //and extending it...
    }
 }

let hexy = new Hexagon(40, 80, 'Ice Gon Kwazy');
// Notice the addition of a new argument
hexy.saySomething();
// "Hi, I am a Hexagon. with Height: 40 and Width: 80"
// "I also like beat boxing and battle rapping in my free time !"
// "My Rapper name is Ice Gon Kwazy bring it !"
              
            
!
999px

Console