I have installed the Resharper extension to visual studio.When i implement the code like below in JavaScript
updateTable();
function updateTable(){
//code here
}
it suggest me to normalise the local declaration,it will change code to like below
function updateTable(){
//code here
}
updateTable();
However both code snippet is work well , Is it important to normalize local declaration?. will it influence page loading performance ? Is it Standard to be followed ?
No, it will not affect performance or do anything negatively. It can make your code look nicer, and I'm guessing that a lot of people consider it to be a good practice, but it does not affect the end result. Before running a script, the browser must download the whole script, regardless of where functions are defined, so it doesn't affect anything. However, note that if you ever use something like var thisIsAFunction=function(){...}
instead of function ThisIsAFunction(){...}
, you WILL need to put that first, otherwise you will get errors.
NL;DR: No, it doesn't matter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With