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

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                // window binding 
// will return the window, undefined in strict mode or the global object in node 
// 'use strict';
// function sound(){
//   console.log(this.bark);
// }

// sound();

// Implicit bind 
// applies to objects with methods 
// it is implied that when we invoke the function, we look to the left of the dot, and that's what 'this' refers to 

// const ada = {
//   name: 'Ada',
//   breed: 'Bali dog',
//   bark: 'woof woof',
//   sound: function(){
//     console.log(this.bark);
//   }
// }

// ada.sound(); // invoking the function 
 
// Explcit Binding 
// .call() - pass in our arguments 1 by 1, it immediately invokes the function
// .apply() - pass in our arugments as an array, it immediately invoke the function 
// .bind() - we pass in our arguments 1 by 1, it does not immediately invoke the function, instead it returns a brand new function that can be invoked later

// function sound(){
//   console.log(this.bark);
// }

// const ada = {
//   name: 'Ada',
//   breed: 'Bali dog',
//   bark: 'woof woof'
// }

// // sound.call(ada);// invoking the function
// const goodDog = sound.bind(ada);

// goodDog();

// new binding 
// when a function is invoked as a constructor using the new keyword this points to the newly created object. 

function Pet(name, breed, bark){
  this.name = name;
  this.breed = breed;
  this.bark = bark;
}

Pet.prototype.sound = function(){
  console.log(this.bark);
}

const ada = new Pet('Ada', 'Bali Dog', 'woof woof');

console.log(ada);

ada.sound();
              
            
!
999px

Console