JavaScript loop through json array

If you are not interested in support for old browsers, the best way to browse an array of json is: var dotArrayJSON = [ {“label”: 1}, {“label”: 2}, {“label”: 3}, {“label”: 4} ]; dotArrayJSON.forEach(loopThrough); function…

Upload text file into textarea via Javascript

How to upload a text file in a textarea with Javascript. This script is used in dotmaui.com to upload files completely client-side, to respect the privacy of users. document.forms[‘myForm’].elements[‘myFile’].onchange = function (evt) { if (!window.FileReader)…

Javascript Trim a String

How remove whitespace from both sides of a string (trim function): Pure Javascript var mystring = ”       dotmaui.com        “; mystring.trim(); For browsers that do not support the trim() method: String.prototype.trim = function() {…

JavaScript – Check if a variable is an integer

function isInt(value) { return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10)); } Tests: isInt(7) // true isInt(“7”) // true isInt(7e5) // true isInt(“7e7″) // true isInt(” 7 “) // true isInt(“”) // false isInt(“…

JS Minify 1.3.2 Released

To make JS Minify more and more complete, we started implementing some options. Version 1.3.2 provides: remove unreachable code drop unreferenced functions and variables join consecutive var statements preserve comments discard calls to console.* functions…