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

              
                <button id="btn">button</button>
              
            
!

CSS

              
                
              
            
!

JS

              
                // 1. 다음은 함수 선언문이다. 함수 표현식으로 바꾸시오.
// 함수 표현식의 우측 익명함수를 arrow 펑션으로 바꾸시오. 한줄이면 충분하다.
function arrow_quiz(x, y) {
  return x + y;
}
console.log(arrow_quiz(1, 2));

// 2. 다음은 리터럴 객체를 리턴하는 함수 표현식이다.
// arrow 펑션으로 바꾸시오.
var arrow2 = function() {
  return {a: 1};
}
console.log(arrow2());

// 3. 입력 파라메터를 a, b, c 순서대로 입력한다. 한꺼번에 입력하는 것이 아니라,
// arrow3(1)(2)(3) 실행결과는 6 이어야 한다.
// 이것얼 curring 펑션이라고 한다.
var arrow3 = function(a) {
  return function(b) {
    return function(c) {
      return a + b + c;
    }
  }
}
console.log(arrow3(1)(2)(3));

// 4. lexical this
var myCat = {
  type: 'Cat',
  legs: 4,
  logInfo: function() {
    console.log('The ' + this.type + ' has ' + this.legs + ' legs');
  }
}
myCat.logInfo();
// 위의 결과는 잘 실행된다. 그러나 아래 결과는 그렇지 않다. 그 이유는 무엇이고 어떻게 수정해야 하는가.
myCat = {
  type: 'Cat',
  legs: 4,
  logInfo: function() {
    setTimeout(function() {
      console.log('The ' + this.type + ' has ' + this.legs + ' legs');
    }, 1000);
  }
}
myCat.logInfo();

// 4-2 lexical this 
$('#btn').click(function () {
  // setTimeout(function () {
    $(this).text('new'); 
  // }, 1000); 
}); 
              
            
!
999px

Console