<script>
//bob first initialization
var bob = function()
{
console.log('bob');
};
//set jan to bob via reference
var jan = bob;
//set bob to another function
bob = function()
{
console.log('newbob');
};
jan(); //console.logs 'bob'
bob(); //console.logs 'newbob'
</script>
问题:
为什么jan()
;输出bob
,不是newbob
吗?因为jan()
是参考bob()