For example, what is the difference between variable query by assignment and direct query? Code 1 varagetCookie (username); if (anull | a) varmempty; Code 2 if (getCookie (username) null | getCookie (username) varmempty, what is the difference between variable query by assignment and direct query?
// Code 1 var a = getCookie ('username'); if (a = null | a = '') var m = 'empty '; // Code 2 if (getCookie ('username') = null | getCookie ('username') = '') var m = 'empty ';
Reply content: in fact, what you said is actually the same as that of the subject. The next one may cause strong discomfort of obsessive-compulsive disorder ...... -0-as you said. 1. performance, but this example is not obvious. It is obvious to query the database.
2. Readability. Obviously, the second one takes a little more time to see. | what are the two variables before and after? The first code shows that the two variables are the same variable at a glance. Reduced coupling?
It is not obvious here. If it involves reading the database, you will know what to use. (Light spray in fact: the code is called once, and the code is called twice. The first method is more efficient.