I always wonder which is the best way to check property of any Object in Javascript. Here is the example
Example 1
1 2 3 4 5 6 7 8 9 10 |
if ("geolocation" in window.navigator) { window.navigator.geolocation.getCurrentPosition(function (position) { //TODO }, function () { //TODO: Still, Countn't find it }); } else { } |
Example 2
1 2 3 4 5 6 |
if ("FB" in window) { FB.Canvas.scrollTo(0, 0); } else { //TODO: Facebook SDK is not initiated } |