2014년 1월 21일 화요일

자바스크립트 인자값 전달

 <script> o = { "h" : 3 }; function obj(v){ v.h = 4; } obj(o); //4 alert(o.h); //객체를 전달하면 참조값을 전달함 o1 = "3"; function str(v){ v = 4; } alert(o1); //3 //원시데이터(number, string, undefined) 등을 전달하면 원본을 복사함 </script>

댓글 없음:

댓글 쓰기