Last active
November 19, 2019 09:56
-
-
Save wallace11/92ea280f837ef3430ec3a5235af9f1da to your computer and use it in GitHub Desktop.
This file contains 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
// Source: http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/ | |
function bytesToSize(bytes) { | |
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | |
if (bytes === 0) return 'n/a'; | |
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); | |
if (i === 0) return bytes + ' ' + sizes[i]; | |
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]; | |
} | |
function formatBytes(a,b) { | |
if (0 == a) return "0 Bytes"; | |
var c = 1024, d = b||2, e= ["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"], f = Math.floor(Math.log(a)/Math.log(c)); | |
return parseFloat((a/Math.pow(c,f)).toFixed(d))+" "+e[f]; | |
} |
This file contains 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 check = OBJECT.find(function(obj) { | |
return obj.id == id; | |
}); |
This file contains 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 output = ''; | |
var object = $$$; | |
for (var property in object) { | |
output += property + ': ' + object[property]+'; '; | |
} | |
console.log(output); |
var | let | const |
---|---|---|
function scoped | block scoped | block scoped |
undefined when accessing a variable before it's declared | ReferenceError when accessing a variable before it's declared | ReferenceError when accessing a variable before it's declared |
Cant be reassigned |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment