JavaScript

Number
// e.g. util_round( 3.105, 0.01 ) = 3.11 function util_round( number, precision ) { return Math.round( number / precision ) * precision; }

Array
var my_array = [ "a", "b", "c" ]; my_array.push( "d" ); alert( my_array.join( '\n' ) );

my_array.pop; alert( my_array.join( '\n' ) );

get current time
var now = new Date.getTime; alert( now );

set timeout
setTimeout( "alert('hello');", 1000 ); // 1 seconds

Preloading Image
var my_image; my_image = new Image; my_image.onload = function { // do sth } my_image.src = "image.png";
 * Ref: http://www.techrepublic.com/article/preloading-and-the-javascript-image-object/5214317

function convert_latlon_to_point3d( lat, lon, radius )
function convert_latlon_to_point3d( lat, lon, radius ) { var r_reduced = Math.cos( util_deg_to_rad( lat ) ) * radius;

var xx = Math.sin( util_deg_to_rad( lon ) ) * r_reduced; var yy = Math.sin( util_deg_to_rad( lat ) ) * radius; var zz = Math.cos( util_deg_to_rad( lon ) ) * r_reduced; var point = new Object; point.x = xx; point.y = yy; point.z = zz; return point; }

function deg_to_rad( degrees )
function deg_to_rad( degrees ) { return degrees * Math.PI / 180; }

function get_element_text_content( element_id )
function get_element_text_content( element_id ) { var element = document.getElementById( element_id ); if ( ! element ) {   return false; } return element.textContent; }