brettz9
06-06-2005, 04:36 PM
Hello,
I am new to Javascript, so please bear with me.
I was examining the bookmarklet "Sort Tables" here (http://www.squarefree.com/bookmarklets/pagedata.html) and it contained a function ITSELF enclosed in pareentheses:
(function(){
var j, thead;
for(j=0;j<g_tables.length;++j){
thead=g_tables[j].createTHead();
insAtTop(thead, makeHeader(j,countCols(g_tables[j])))
}
}) ();
As this script did not work with the parentheses removed, I am wondering what this does. Please note: I am referring to the function declaration being itself enclosed not the arguments passed to it.
thanks,
Brett
I am new to Javascript, so please bear with me.
I was examining the bookmarklet "Sort Tables" here (http://www.squarefree.com/bookmarklets/pagedata.html) and it contained a function ITSELF enclosed in pareentheses:
(function(){
var j, thead;
for(j=0;j<g_tables.length;++j){
thead=g_tables[j].createTHead();
insAtTop(thead, makeHeader(j,countCols(g_tables[j])))
}
}) ();
As this script did not work with the parentheses removed, I am wondering what this does. Please note: I am referring to the function declaration being itself enclosed not the arguments passed to it.
thanks,
Brett