Last active
July 6, 2016 05:14
-
-
Save JohnBaek/273d13190f9f0dd9894dcab5b5707144 to your computer and use it in GitHub Desktop.
JS_string_to_array.js
This file contains 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
<html> | |
<head> | |
<script> | |
var Draw = function() { | |
this.str = new Array(); | |
}; | |
Draw.prototype.layout = function(){ | |
var a = this.str; | |
this.str[this.str.length] = '<div id="DAUM_GAME_HEADER_WRAP">'; | |
console.log(a); | |
console.log(this.str); | |
this.str[this.str.length] = ' <div id="DAUM_GAME_HEADER">'; | |
console.log(a); | |
console.log(this.str); | |
a[a.length] = ' <ul id="gh_service_title">'; | |
console.log(a); | |
console.log(this.str); | |
a[a.length] = ' <li class="logo_daum_game"><a href="http://game.daum.net/" target="_top">Daum게임</a></li>'; | |
console.log(a); | |
console.log(this.str); | |
a[a.length] = " </ul>"; | |
a[a.length] = ' <ul id="game_header_category">'; | |
this.category(); | |
//console.log(a); | |
}; | |
function test(){ | |
var test = new Draw(); | |
//이때 값복사가 아닌 주소값 복사가 이뤄진다 즉 | |
//0000x0x.. -> 같은 값이 그대로 카피 됨 | |
var a = test.str; | |
test.str[test.str.length] = '1'; | |
test.str[test.str.length] = '1'; | |
test.str[test.str.length] = '1'; | |
console.log(test.str); | |
console.log(a); | |
var test2 = "test"; | |
//이때는 당연 값복사가 이뤄짐 | |
var c = test2; | |
test2 += "1"; | |
test2 += "1"; | |
test2 += "1"; | |
test2 += "1"; | |
console.log(test2); | |
console.log(c); | |
} | |
//Makes category | |
Draw.prototype.category = function(){ | |
that = this.str; | |
var c_Length = that.length; | |
that[c_Length++] = ' 1'; | |
that[c_Length++] = ' 2'; | |
that[c_Length++] = ' 3'; | |
//console.log(this.str === that); | |
}; | |
var a = new Draw(); | |
//a.layout(); | |
test(); | |
</script> | |
</head> | |
<body></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment