Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                //通过json生成对象的原始模式
var cat1 = {}; // 创建一个空对象
cat1.name = "大毛"; // 按照原型对象的属性赋值
cat1.color = "黄色";
var cat2 = {};
cat2.name = "二毛";
cat2.color = "黑色";

//原始模式的改进
function Cat2(name,color){
  return {
    name:name,
    color:color
  }
}

//构造函数模式
function Cat3(name,color){
  this.name=name;
  this.color=color;
}

//Prototype模式
function Cat4(name,color){
  this.name = name;
  this.color = color;
}
Cat4.prototype.type = "猫科动物";
Cat4.prototype.eat = function(){alert("吃老鼠")};

//Prototype验证方法
var human = function() {}
var socrates = Object.create(human);
console.log(human.isPrototypeOf(socrates)); //=> true
//console.log(socrates.prototype.isPrototypeOf(human));
console.log(socrates instanceof human); //=> false
//console.log(socrates.prototype)


              
            
!
999px

Console