. Accessibility issues can be solved through Solved by shortcut keys and other methods. This can better restore the semantics of HTML elements.
Simple for loop optimization
When you write a for loop, there is a very simple trick that can improve performance.
for ( var i = 0; i < elements.length; i )
Use the following statement instead of the above:
for (var i = 0, j = elements.length; i < j; i )
This way, the number of elements (the value of elements.length) can be stored in a variable j, so there is no need to Count the number of elements each time through the loop.
Use anonymous functions as event handlers
Especially for short functions, creating an anonymous function can be more readable than using a reference to a named function.
anchor.onclick = function() { map.goToPosition( home ); return false; }
March: It is more efficient to use named functions when developing more complex JavaScript.
Use Array.join instead of concatenating strings
When concatenating many strings, variables, etc. into a long string, combine all strings and Put the variables into an array, and then use the join method to form them into a long string, which is better than string concatenation in terms of code readability and performance.
var text = 'There are' elements.length 'members in the elements array.';
var text = ['There are', elements.length, 'members in the elements array.'].join(' ');