Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229115

Ionic native Screen Orientation plugin not working

$
0
0

So, this is a weird concept in Javascript. this merely refers to the calling context at any given point. Which means that if you define function hai(isGenuine: boolean) { ... }
...and you call hai(true);, depending on where you call it this may or may not actually refer to your class.

For example, If you were to do
setTimeout(function() { hai(false); }, 1000};

this would refer to the window object. Which of course is not what you want.

So, then Typescript comes along and starts introducing classes, and says hey..."this" whole thing has become a problem. So they introduce fat arrows, which in short properly maintains the concept of this to always refer to your class. Even if you do
setTimeout(() => { hai(false; }, 1000};
this will still refer to your class.

Hopefully that makes sense. I don't feel like I've gotten any better conveying all of this in a succinct and explanatory manner :stuck_out_tongue:.

For more information you can look here: Arrow Functions.


Viewing all articles
Browse latest Browse all 229115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>