How to refine conditional branch statements into functions by JavaScript
Editor to share with you JavaScript how to extract conditional branch statements into functions, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Refine the conditional branch statement into a function
Complex conditional branching statement is an important reason why the program is difficult to read and understand, and it is easy to lead to a huge function. Sometimes conditional branch statements can be refined into semantic functions to make the code more intuitive and logical.
/ / function getPrice (price) {var date = new Date (); if (date.getMonth () > = 6 & & date.getMonth () = 6 & & date.getMonth ())