Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Thats an anonymous self executing function. This might help: http://esbueno.noahstokes.com/post/...
-
@practiseSafeHex I skipped over it a bit, seems like that's gonna be really helpful
Thanks a lot ;D
Let's see if I can get my code to start working again -
Wait, the whole fucking code should be inside of that function?
*goes back to reading* -
@aile11 ha yes. For this reason, this is not my preferred way of using Javascript.
-
@aile11 it depends what it is you are actually trying to do. Could use a window.onload event for example.
But I don't know the context. All I can say is, when ever I see code online doing that, the first thing I have to do is take it out of the anon function so that I can integrate it with my code.
It's a horrible way to do things as it's very anti-collaboration and frustrating to deal with -
@practiseSafeHex the only thing it should do is execute my code, I guess I'll use window.onload() then
Thank you for your tips o/ -
Wack61259yGuys and girls, I'm proud, so far,no one sugested to use jQuery (pretty sure on SO there would be a bunch of use this jQuery on load or on ready function stuff) -
@pascalwacker sorry, but I'm not using jquery atm
Maybe I'll get into it in the future, but not for now -
Wack61259y@aile11 wasn't sugesting to use it ;) it should have been a sarcastic comment about every one on SO telling every one with little expirience, to use it (even if it is completly unnecessary) -
svidlak649yYou can write your functions below the self executed one and just call the functions inside it -
@osmarks I'm still learning, so better ask others ;D
But I guess it's mainly for side functions which may not get interfered by another function
Related Rants

What only relying on JavaScript for HTML form input validation looks like
Found something true as 1 == 1
Trying to write some JavaScript (still learning it)
Why does the fucking
(function() {
})();
not work for starting a function below it?
Or above... I tried to fiddle with it too much, I'm just gonna leave it for now
undefined
fuck it
js
not working
function()