Hi guys, It seems stupid question but I'm seeking the best practice so it won't get me headache in the future. I need to declare an empty variable. Its value would then set as stream data (some times during the day) at a rate around 8k bytes every 16ms. So what is the best practice between these options: var streamDataValue; var streamDataValue = null; var streamDataValue = false; Code (markup): At the end of the day I would stop receiving the stream with: streamDataValue.stop(); // release the stream to receive new one Code (markup): Hope you get the picture. Thank you, Edit: Data is string not array.
Why don't you declare it on demand - ie, when you need it? Do you have to have the variable set to false or null or just exist before you actually use it?
Yes, they aren't in used before data is filled. So the variables are empty if there is no data. I have no idea how to declare these global variables. They will be used in different functions.
Honestly if the difference between any of those matters, you are doing something wrong. If you want it global in scope, declare them ANY of those ways outside your functions, and boom you have a global. You don't have to say "null" or "false". Though I'd probably NOT be trying to make them global and instead try to isolate their scope or pass the values somehow... but that would depend on how the code you are writing functions and what it is you are actually trying to do -- and just how much framework asshattery is pissing on things.