JSFiddle - React, Tailwind, and code Playground

by tonyleeper

JavaScript

/**
    navigator.geolocation
*/

var sdl = {}
sdl.utils = {
    log : function (value) {
        document.write(value);
        document.write("<br />");
    }   
}

String.prototype.repeat = function(times) {
   return (new Array(times + 1)).join(this);
}

Object.prototype.reflect = function() {
    var reflectOn = function(object, depth) {
        var indent = "- ".repeat(depth);
        
        for (var propertyName in object) {
            if (propertyName !== 'reflect')
            {
                sdl.utils.log(indent + propertyName);
                reflectOn(object[propertyName], depth + 1);
            }
        }     
    }
    
    reflectOn(this, 0);
}

navigator.geolocation.getCurrentPosition(function (position) {
    sdl.utils.log(position.coords.latitude);
    sdl.utils.log(position.coords.longitude);
    
    position.reflect();
});