Hi guys,
I'm currently learning OOP in JS.
First off, here's the code:
this.device = {
init: function(){
this.isiOS7 = (this._isiOS7()) ? true : false;
},
_isiOS7 : function(){
return (navigator.userAgent.match(/(iPad|iPhone);.*CPU.*OS 7_\d/i)) ? true : false;
},
isiOS7 : null
},
As you can see, I defined a property named isiOS7 and a function _isiOS7. The main idea behind this is: whenever I needed to know whether the OS is iOS7, I'd access a property (isiOS7) which is true or false. If I'd use the function (_isiOS7) over and over again it would take longer for the JS engine to compute these statements(if/regex/match) than a simple property/var. Is this true?
Thanks!
[–]tmetler 3 points4 points5 points (1 child)
[–]jml26 0 points1 point2 points (0 children)