2016-02-12
c와 같은 언어에서는 임의의 변수를 값참조인지 주소참조인지를 연산자를 써서 정의해줄 수 있다.
하지만, 자바스크립트에서는 데이터 형에 따라서 해당 사항이 결정 된다.

값 참조 : 데이터형 변수들(number, string, boolean, undefined, null)
주소 참조 : 객체형 변수들(array, object, date)

<script>
a = 'a';
function aa(a)
{
    a = 'b';
}
aa(a);
document.write('a : ' + a + '<br>');

b = ['a','b'];
function bb(b)
{
    b.push('c');
}
bb(b);
document.write('b : ' + b + '<br>');

t = new Date();
function tt(t)
{
    t.setHours('3');
}
tt(t);
document.write('t : ' + t);
</script>