JavaScript warning - used before defined?
Hi there,
When compiling I get the following message, prob' because I have the functions at the bottom of the JS file:
[WARN] JavaScript compiler reported "'getData' was used before it was defined." at people.js:232
Everything appears to be working and I find it makes code more readable to have functions at the end.
Is there a problem with this approach/do I need to address this?
cheers
Chris
2 Answers
-
Accepted Answer
Pretty sure Ti uses jslint to parse for errors, which is pretty picky.
I generally keep all of my contained function in a separate file and then include it, before using any of them.
Don't think your approach will affect your build though
-
That's a good method Nick - I've been pondering how to organise the code - most functions are data access (running API calls and parsing results). so grouping them into a separate include file could help reuse as well. i.e. I could reference the same include file in multiple contexts and return the result to whichever one was active.
Marvellous, thanks
Chris.