0

I am using this logic for some simple template logic in angular 1.5:

<p ng-if="myData.type !== 'customer'"></p> 

Would it be be faster from a performance perspective to use numbers instead of a string comparison?? ie

<p ng-if="myData.type !== '0'"></p> ?
SD Dev
  • 335
  • 3
  • 10
  • Your question might be equally valid when asking the same about Javascript (q.v. [here](http://stackoverflow.com/questions/23836825/is-javascript-string-comparison-just-as-fast-as-number-comparison)). The answer would depend on the particular implementation of JS for a given browser. – Tim Biegeleisen Nov 14 '16 at 01:19
  • Actually both cases shown are strings since you quoted `'0'` – charlietfl Nov 14 '16 at 01:40

1 Answers1

-1

String comparisons are slightly slower, but barely. The difference will not be noticeable if the strings are shorter than 100 characters, and there are fewer than a million comparisons. Use strings if it is easier.

Gavin Haynes
  • 1,721
  • 11
  • 21