View Single Post
  #2 (permalink)  
Old November 9th, 2011, 01:19 PM
irProject irProject is offline
Friend of Wrox
Points: 742, Level: 10
Points: 742, Level: 10 Points: 742, Level: 10 Points: 742, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2009
Location: Tehran, Iran
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default The answer

Hello,
I myself found the answer.
these are some ways to write less code. as you know the next line refers to a function:
Code:
function x(arg){ /*some codes here ...*/ }
what about this: ?
Code:
(function x(arg){ /*some codes here ...*/ })
we can call a function by passing parameters like:
Code:
x(3);
so ...
Code:
(function (a){ /* ... */ })(window);
means passing 'window' object as parameter 'a' to the defined function. in the body of this function , 'a' points to 'window'
Reply With Quote