Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Any issues with combining logic?

Posted on 2014-04-09
5
Medium Priority
?
120 Views
Last Modified: 2014-04-09
I'm streamlining my code and I did the following;
    var currVarNm = aa.varMapping('deviceType','props');
    window[aa.prefix][currVarNm] = deviceType.toLowerCase();

Open in new window


and combined to:
window[aa.prefix][aa.varMapping('deviceType','props')] = deviceType.toLowerCase();

Open in new window


Any issues doing this? It works but I haven't checked on anything other than FF.
0
Comment
Question by:894359
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39989534
I'm not sure what the point is since it doesn't speed it up any and makes it harder to read and maintain.  Almost all interpreters these days precompile the code, they don't run it exactly as you type it.  So any attempts at shortcuts are usually meaningless and just make it more difficult to maintain.
0
 

Author Comment

by:894359
ID: 39989757
I just wanted to minimize the # of lines for some code. So you think it is a bad idea then?
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 39989823
Yes, I think it is a bad idea.  I never try to minimize the lines of code.  I try to make it easy for me, the human, to understand because I am the one who has to maintain and modify it.  And the machine doesn't care.  What you did does not minimize the code that is actually run.

In general, I say do not try to be 'clever'.  Write code that you can understand next week or next month.  That is especially true the first time around.  If you can get your code to work when it is clear you might be able to see things that you actually can do better.  But minimizing the lines is rarely going to do that.
0
 

Author Closing Comment

by:894359
ID: 39989931
Thanks!
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39990001
You're welcome, glad to help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question