JohnBaek
7/6/2016 - 12:03 AM

JS_string_to_array.js

JS_string_to_array.js

<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>