below is function i want to use
(function () {
var url = param_url;
})(); // what are these ending curly brackets for ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The 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:
…and then the parens call it. it’s the same as:
…aside from the use of
v, of course. So to pass an argument to it, just do this: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.