Solved

Any issues with combining logic?

Posted on 2014-04-09
5
118 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 83

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 83

Accepted Solution

by:
Dave Baldwin earned 500 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 83

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…
Suggested Courses

615 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