stillmember.blogg.se

Js function showhide
Js function showhide








js function showhide

A function called isLegalDrinkingAge() makes more sense than isOverEighteen() as the legal drinking age varies from country to country, and there are other things than drinking to consider that are limited by age. One trap to avoid is marrying values and functionality in names. None of these make much sense - good variable and function names should be easy to understand and tell you what is going on - not more and not less. This is a no-brainer but it is scary how often you will come across variables like x1, fe2 or xbqne in JavaScript, or - on the other end of the spectrum - variable names like incrementorForMainLoopWhichSpansFromTenToTwenty or createNewMemberIfAgeOverTwentyOneAndMoonIsFull. However, I have found that following these principles has made me a more effective developer and allowed other developers to build upon my work more easily.Ĭall things by their name - easy, short and readable variable and function names I am sure you will find things to disagree with, and that is a good thing - you should question what you read, and strive to find better solutions. Take the advice below to heart and keep it in a part of your brain that has a quick access route so you can apply it without thinking about it. So I’ve decided to make it easier for you by creating this article, which is a compilation of best practices and good advice I’ve amassed over the years, much of it learnt the hard way (experimentation and suchlike).

#JS FUNCTION SHOWHIDE CODE#

However, looking around the web and getting code handed over to me from other developers for years has taught me that common sense is actually quite a rarity in live code on the web, and the “sensible and logical thing to do” gets pushed far down the priority list once you are in the middle of a project, and the deadline is looming. To a number of you, what you are about to read will appear to be very obvious and just the sensible thing to do. Writing a best practice article is quite a tricky business. 16 Add functionality with JavaScript, don’t create too much content.10 Allow for configuration and translation.7 Use shortcut notation when it makes sense.5 Comment as much as needed but not more.2 Call things by their name - easy, short and readable variable and function names.










Js function showhide