Pen Settings



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


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.






                var name = 'window'

function Person (name) { = name
    this.foo1 = function () {

    this.foo2 = () => console.log(

    this.foo3 = function () {
        return function () {

    this.foo4 = function () {
        return () => { console.log( }

var person1 = new Person('person1')
var person2 = new Person('person2')

person1.foo1() // person1  (隐式绑定) // person2 (显示绑定person2,显示绑定优先级高于person1.foo1的隐式绑定)

person1.foo2() // person1  (上层作用域中的this是person1函数) // person1 (显示绑定在箭头函数中无效,所以结果还是上层作用域中的this是person1函数)

person1.foo3()() // window (person1.foo3()得到返回函数 加小括号进行直接调用 this指向全局作用域window) // window (得到返回函数后,独立函数调用指向全局)
person1.foo3().call(person2) // person2 (person1.foo3()得到返回函数后,显示绑定person2)

person1.foo4()() // person1 (箭头函数中没有this,向上一层作用域找 this指向person1) // person2 (显示绑定person2,得到返回的箭头函数后,向上一层作用域找,this指向person2)
person1.foo4().call(person2) // person1 (person1.foo4()得到返回箭头函数显示绑定person2无效,向上一层作用域找,this指向person1)