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 cat = { | |
name: 'James', | |
age: 2 | |
};//cat κ°μ²΄ μμ± | |
console.log(cat.toString());//[object Object] μΆλ ₯ | |
console.dir(cat); |
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
//Array μμ±μλ‘ λ°°μ΄ μμ± | |
var a = new Array(1);//μμ±μμ μΈμκ° νλμΌ λ ν΄λΉ μΈμκ° λ°°μ΄μ ν¬κΈ°κ° λλ€. | |
var b = new Array(1,2,3,4);//μμ±μμ μΈμκ° μ¬λ¬ κ°μΌ λ μΈμλ€μ΄ λ°°μ΄μ μμκ° λλ€. | |
//λ°°μ΄ λ¦¬ν°λ΄λ‘ λ°°μ΄ μμ± | |
var c = [1,2,3]; | |
console.log(a[0],a[1]);//undefined, undefined μΆλ ₯ | |
console.log(b[0],b[1]);//1 2 μΆλ ₯ | |
console.log(c[0],c[1]);//1 2 μΆλ ₯ |
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 a = [1,2,3,,4];//[1,2,3,empty,4] λ°°μ΄ μμ± | |
var b = [1,2,3,,,4];//[1,2,3,empty,empty,4] λ°°μ΄ μμ± | |
var c = [1,2,3,4,,];//[1,2,3,4,empty] λ°°μ΄ μμ± |
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 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] μΆλ ₯ |
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 a = [1,2,3,4]; | |
delete a[1]; | |
console.log(a);//[1,empty,3,4] μΆλ ₯ |
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 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)] μΆλ ₯ |
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 add(a,b) { | |
return a + b; | |
} |
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 add = function(a,b) { | |
return a + b; | |
} |
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 add = function plus(a,b) { | |
return a + b; | |
} |
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
add(1,2);//3 | |
function add(a,b) { | |
return a + b; | |
} | |
add(3,4);//7 |