Created
August 14, 2020 02:08
-
-
Save Elbone/6002b6f2518ba738fe3f04beede73fbb to your computer and use it in GitHub Desktop.
Useful js
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
// LOOP ARRAY KEYS and INDEXES | |
let myArray = ['fruit', 'fish', 'seahorses', 'mudslides']; | |
for (let [index, value] of myArray.entries()) { | |
console.log(index, value); | |
} | |
/* | |
0 "fruit" | |
1 "fish" | |
2 "seahorses" | |
3 "mudslides" | |
*/ | |
// GET OBJECT KEYS | |
let myObj = { | |
a: 1, | |
b: 'Data', | |
c: false | |
}; | |
console.log(Object.keys(myObj)); // ["a", "b", "c"] | |
console.log(Object.values(myObj)); // [1, "Data", false] | |
// ACCESS UPLOADED FILE DATA | |
// HTML: <input type="file" multiple> | |
myInput.addEventListener('change', function () { | |
myFiles = myInput.files; | |
console.log(myFiles[0].name); | |
console.log(myFiles[0].size); | |
console.log(myFiles[0].lastModified); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment