What is the difference between variable query by assignment and direct query?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.