Skip to content

Instantly share code, notes, and snippets.

View khg0712's full-sized avatar
🎯
Focusing

Hugo Kim khg0712

🎯
Focusing
View GitHub Profile
@khg0712
khg0712 / JS-function-type-Example7.js
Created May 19, 2018 16:35
ν•¨μˆ˜ ν‘œν˜„μ‹ ν•¨μˆ˜ ν˜Έμ΄μŠ€νŒ… 비ꡐ μ˜ˆμ‹œ
add(1,2);//μ—λŸ¬ λ°œμƒ
var add = function(a,b) {
return a + b;
};
add(1,2);//3 λ°˜ν™˜
@khg0712
khg0712 / JS-function-type-Example6.js
Created May 19, 2018 16:32
Function μƒμ„±μžλ₯Ό ν†΅ν•œ ν•¨μˆ˜ 생성 μ˜ˆμ‹œ
var add = new Function('a','b','return a + b');
add(1,2);//3 λ°˜ν™˜
@khg0712
khg0712 / JS-function-type-Example5.js
Created May 19, 2018 16:30
κΈ°λͺ… ν•¨μˆ˜ ν‘œν˜„μ‹ μž¬κ·€ν•¨μˆ˜ μ˜ˆμ‹œ
var factorial = function factorialFunc(num) {
if(num <= 1) {
return num;
}
return (num * factorialFunc(num-1));
};
console.log(factorial(3));//6 λ°˜ν™˜
@khg0712
khg0712 / JS-function-type-Example4.js
Created May 19, 2018 16:26
ν•¨μˆ˜ ν˜Έμ΄μŠ€νŒ… μ˜ˆμ‹œ
add(1,2);//3
function add(a,b) {
return a + b;
}
add(3,4);//7
@khg0712
khg0712 / JS-function-type-Example3.js
Created May 19, 2018 16:23
κΈ°λͺ… ν•¨μˆ˜ ν‘œν˜„μ‹ μ˜ˆμ‹œ
var add = function plus(a,b) {
return a + b;
}
@khg0712
khg0712 / JS-function-type-Example2.js
Created May 19, 2018 16:21
ν•¨μˆ˜ ν‘œν˜„μ‹ μ˜ˆμ‹œ
var add = function(a,b) {
return a + b;
}
@khg0712
khg0712 / JS-function-type-Example1.js
Last active May 19, 2018 16:22
ν•¨μˆ˜ μ„ μ–Έλ¬Έ μ˜ˆμ‹œ
function add(a,b) {
return a + b;
}
@khg0712
khg0712 / JS-array-type-Example5.js
Created May 12, 2018 14:55
splice λ©”μ„œλ“œ μ‚¬μš©λ°©λ²•
var a = [1,2,3,4,5];
a.splice(1,2);
console.log(a);//[1,4,5] 좜λ ₯
a.splice(3,0,'a','was',[1,4,5]);
console.log(a);//[1, 4, 5, "a", "was", Array(3)] 좜λ ₯
@khg0712
khg0712 / JS-array-type-Example4.js
Created May 12, 2018 14:40
λ°°μ—΄μ—μ„œμ˜ delete μ—°μ‚°μž μ‚¬μš©
var a = [1,2,3,4];
delete a[1];
console.log(a);//[1,empty,3,4] 좜λ ₯
@khg0712
khg0712 / JS-array-type-Example3.js
Last active May 12, 2018 14:58
length ν”„λ‘œνΌν‹° μ‚¬μš© 예
var a = [1,2,3,4,5,6];//λ°°μ—΄ 생성
console.log(a.length);//6 좜λ ₯
a.length = 2;
console.log(a.length);//2 좜λ ₯
console.log(a);//[1,2] 좜λ ₯