This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testObject = { | |
pi: Math.PI, | |
e: Math.E, | |
one: 1, | |
x: 1.5, | |
str: "1.2345" | |
}; | |
var places = 2, | |
json = JSON.stringify(testObject, function(key, value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Save a text file locally with a filename by triggering a download | |
*/ | |
var text = "hello world", | |
blob = new Blob([text], { type: 'text/plain' }), | |
anchor = document.createElement('a'); | |
anchor.download = "hello.txt"; | |
anchor.href = (window.webkitURL || window.URL).createObjectURL(blob); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Trigger a file open dialog and read local file, then read and log the file contents | |
*/ | |
var element = document.createElement('div'); | |
element.innerHTML = '<input type="file">'; | |
var fileInput = element.firstChild; | |
fileInput.addEventListener('change', function() { | |
var file = fileInput.files[0]; |