Anonymous function is a block of code that directly executed like there's no function.
>> (function(){
>> var doc = document.getElementById('satu');
>> doc.innerHTML = "Luna Maya";
>> })();
If you declare a function in inner the anonymous function, you should call it in the inner also.
>> (function(){
>> function lol(){
>> var doc = document.getElementById('satu');
>> doc.innerHTML = "Luna Maya";
>> }
>> lol();
>> })();
Here's a simple code:
<script>
function show(msg){
alert(msg);
}
show((function(){
return 'hello, lady gaga';
})());
</script>
Here's a simple code:
<script>
function show(msg){
alert(msg);
}
show((function(){
return 'hello, lady gaga';
})());
</script>
No comments:
Post a Comment