재우니의 블로그

 

 

 

 

Using addition operator ( + ) :

 
<html>
<body>
<script type="text/javascript">
 var str1 = "Welcome";
 var str2 = "To";
 var str3 = "Javascript";
 var result = str1 +" "+ str2 +" "+ str3;
 document.write(result);
</script>
</body>
</html>

 

Using the assignment operator (+=)

 
<html>
<body>
<script type = "text/javascript">
 var str1 = "Welcome";
 str1 += " To";
 document.write(str1);
 </script>
</body>
</html>

Using the ‘  concat ‘ method

 
<html>
<body>
<script type="text/javascript">
 var str1 = "".concat("Welcome" ,"To ","Javascript");
 document.write(str1);
</script>
</body>
</html>

 

 

However multiple ways exists, the addition operator ( + ) is widely used one

 

** join 함수도 사용해 봤음.

.join() 사용할때 () 그냥 닫으면 , 값이 나옴. 그래서 "" 처리함..

병합 이후에 join 함수 부분 체크가 들어가므로 약간 성능이 느리지 않을까 생각되지만, ...

성능 부분은 구글링을 해서 찾아보심이..

 

var conMenu = [
            '<ul id="basicMenu_<%=TabPortletID%>_<%=PortletID%>" class="contextMenu">',
            '<li class="del"><a href="#del"><%=GetResource("DelPortlet")%></a></li>',
            '<li class="min"><a href="#min"><%=GetResource("SmallPortlet")%></a></li>',
            '<li class="max"><a href="#max"><%=GetResource("LargePortlet")%></a></li>',
            '</ul>'
        ].join("");