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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                let obj = {
  singer: "周杰伦"
};
let value = "青花瓷";
Object.defineProperty(obj, "music", {
  // value: '七里香', // 设置属性的值 下面设置了get set函数 所以这里不能设置
  configurable: false, // 是否可以删除属性 默认不能删除
  // writable: true,  // 是否可以修改对象 下面设置了get set函数 所以这里不能设置
  enumerable: true, // music是否可以被枚举 默认是不能被枚举(遍历)
  // ☆ get,set设置时不能设置writable和value,要一对一对设置,交叉设置/同时存在 就会报错
  get() {
    // 获取obj.music的时候就会调用get方法
    // let value = "强行设置get的返回值"; // 打开注释 读取属性永远都是‘强行设置get的返回值’
    return value;
  },
  set(val) {
    // 将修改的值重新赋给song
    value = val;
  }
});

console.log(obj.music); // 青花瓷
delete obj.music; // configurable设为false 删除无效
console.log(obj.music); // 青花瓷

obj.music = "听妈妈的话"; // writable要设为false 是不能修改
console.log(obj.music); // 听妈妈的话

for (let key in obj) {
  // 默认情况下通过defineProperty定义的属性是不能被枚举(遍历)的
  // 需要设置enumerable为true才可以 否则只能拿到singer 属性
  console.log(key); // singer, music
}
              
            
!
999px

Console