Home › Forums › JavaScript › Nesting functions
- This topic is empty.
-
AuthorPosts
-
March 5, 2012 at 10:34 pm #36999
joshuanhibbert
MemberI’m in the middle of learning JS and jQuery. I try and create a random tool at least once a week to test how my learning is going, and this is my latest experiment: http://jsfiddle.net/joshnh/UBQvL/
Now, originally, I was using nested for loops (http://jsfiddle.net/joshnh/UBQvL/9/), but I have since discovered that this is a bad idea for performance reasons. I have defined functions to try and get around this, but is defining a function inside another function just as bad?
What is the best way to do what I am trying to do? Have you got any other improvements for me? Thanks in advance guys.
Slightly related aside; should I define a function like this:
function foo() {
...
};Or like this:
var foo = function() {
...
};March 7, 2012 at 6:44 am #98341tobeeornot
Member@joshuanhibbert – nice application, josh. I am also learning jquery at the moment and was wondering how you go about setting yourself projects? I am working purely off exercise files at the moment and thought it would be good to move away from that and do my own stuff. The problem is I find it hard choosing what to do. Any suggestions?
March 7, 2012 at 7:38 am #98349tobeeornot
MemberGreat idea. Thanks @karlpcrowley
March 7, 2012 at 6:09 pm #98418joshuanhibbert
Member@Hompimpa LOL! You and your forking antics ;)
@tobeeornot I struggle with finding things to create and practise with too, but any time something pops into my head (usually from a discussion with someone) I attempt to create a tool. I much prefer creating my own stuff over following tutorials, and I find that having to figure out issues on my own is the best way to learn. The other thing I do is try to recreate popular things on my own. Things like this, this, this, this, this, this, this, and this.Not all of those are working 100%, but feel free to play around with them!
@karlpcrowley Thanks for those links mate, I’ll have a look at them now! Great looking fork too :DMarch 7, 2012 at 7:19 pm #98429joshuanhibbert
Member@karlpcrowley That article explained defining functions perfectly. Thanks Karl!
Also, that inception gist is awesome!
March 8, 2012 at 6:07 am #98472tobeeornot
Member@joshuanhibbert – thanks very much for that. I think that is really good advice. Sometimes I am keen to move on quickly after finishing tutorials and come to doubt myself later as to how much I have absorbed. I think what you are doing sounds like the best method.
March 8, 2012 at 4:49 pm #98520joshuanhibbert
Member@tobeeornot No worries. Good luck with your learning!
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.