Skip to content

Instantly share code, notes, and snippets.

@Elbone
Created August 14, 2020 02:08
Show Gist options
  • Save Elbone/6002b6f2518ba738fe3f04beede73fbb to your computer and use it in GitHub Desktop.
Save Elbone/6002b6f2518ba738fe3f04beede73fbb to your computer and use it in GitHub Desktop.
Useful js
// 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