This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foo() // Uncaught TypeError: foo๋ ํจ์๊ฐ ์๋๋๋ค | |
| var foo = function() { | |
| console.log('FOOOOO') | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const transformNamesToUppercase = function(names) { | |
| const results = []; | |
| for (let i = 0; i < names.length; i++) { | |
| results.push(names[i].toUpperCase()); | |
| } | |
| return results; | |
| }; | |
| transformNamesToUppercase(names); // ['IRISH', 'DAISY', 'ANNA'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function curry(fn) { | |
| if (fn.length === 0) { | |
| return fn | |
| } | |
| function _curried(depth, args) { | |
| return function(newArgument) { | |
| if (depth - 1 === 0) { | |
| return fn(...args, newArgument) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log('This is line one.\n' + | |
| 'This is line two.'); | |
| // This is line one. | |
| // This is line two. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ๋ณ์ ๊ตํ | |
| let a = 1 | |
| let b = 3 | |
| ;[a, b] = [b, a] | |
| console.log(a) // 3 | |
| console.log(b) // 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function foo() { | |
| // ํจ์ ๋ด์์ ๋ชจ๋ ๋ณ์์ ์ ๊ทผํ ์ ์์ต๋๋ค. | |
| var bar = 'bar' | |
| let baz = 'baz' | |
| const qux = 'qux' | |
| console.log(bar) // "bar" | |
| console.log(baz) // "baz" | |
| console.log(qux) // "qux" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var person = { name: 'Tyler', age: 28 }; | |
| console.log('Hi, my name is ' + person.name + ' and I am ' + person.age + ' years old!'); | |
| // 'Hi, my name is Tyler and I am 28 years old!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log(foo) // undefined | |
| var foo = 'foo' | |
| console.log(baz); // ReferenceError: can't access lexical declaration 'baz' before initialization | |
| let baz = 'baz'; | |
| console.log(bar); // ReferenceError: can't access lexical declaration 'bar' before initialization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ES5 ํจ์ ์์ฑ์ | |
| function Person(name) { | |
| this.name = name | |
| } | |
| // ES6 ํด๋์ค | |
| class Person { | |
| constructor(name) { | |
| this.name = name | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var foo = 'foo' | |
| var foo = 'bar' | |
| console.log(foo) // "bar" | |
| let baz = 'baz' | |
| let baz = 'qux'; // Uncaught SyntaxError: Identifier 'baz' has already been declared |