below is function i want to use
(function () {
var url = param_url;
})(); // what these ending curly brackets do ?
views:
25answers:
2The ending parentheses (()) call the function. You can pass arguments to it by putting them within the parentheses.
What you have there is a function expression which is then immediately called. The function expression is:
(function () { var url = param_url; })
...and then the parens call it. it's the same as:
var v = function () { var url = param_url; };
v();
...aside from the use of v, of course. So to pass an argument to it, just do this:
(function (argname) { var url = param_url; })(your_argument_here);
kangax has written up a useful article on function expressions, including browser bugs related to naming the function in the expression (amongst other things), which you should be able to but sadly, can't currently.
T.J thank you very much for the quick reply actually i'm calling this script by including js file like script src="http://www.website.com/script.js?param_url=url"
and in file i have above function