dimanche 5 juillet 2015

Faster Evaluating IF Condition of JavaScript

Back to the basics of JavaScript. This is a question I am coming with is based on computation time speed of JavaScript If condition.

I have a logic which includes usage of if condition. The question is computing equal to value is faster OR not equal to value is faster?

if(vm.currentFeedbackObject.sendReminderLists[0].sendReminderFlag !== '' && vm.currentFeedbackObject.sendReminderLists[0].sendReminderedOn !== null)
            {
              vm.isReminderSectionVisible = true;
            } else
            {
              vm.isReminderSectionVisible = false;
            }

The above one computes not equal to

if(vm.currentFeedbackObject.sendReminderLists[0].sendReminderFlag === '' && vm.currentFeedbackObject.sendReminderLists[0].sendReminderedOn === null)
            {
              vm.isReminderSectionVisible = false;
            } else
            {
              vm.isReminderSectionVisible = true;
            }

The above one computes equal to value

which of both these is faster in execution?

Aucun commentaire:

Enregistrer un commentaire