Create JavaScript array of function pointer, without calling it
- by sibidiba
I have the code below. I would like to have an array (buttons) with a single element pointing to the a function (closeFlag).
<script type="text/javascript">
var closeFlag = new function() {
alert('Clicked');
}
var buttons = {
'OK': closeFlag
}
</script>
However, when loading the page the alert immediately pops up. When the array is constructed, instead of using it as a pointer, JavaScript calls my function.
Why? What mistake, misconception do I have?