Last active
October 13, 2021 01:44
-
-
Save sorie/21034c7bd4254058246fe8230456fbc4 to your computer and use it in GitHub Desktop.
es6 map example
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
const devices = [ | |
{"deviceId":"default","kind":"audioinput","label":"기본값 - 마이크(Realtek Audio)","groupId":"2fc5a70356cd629dff0f57c8c5b420757f34b7f60a40184617607bdf125025f8"}, | |
{"deviceId":"communications","kind":"audioinput","label":"커뮤니케이션 - 마이크(Realtek Audio)","groupId":"2fc5a70356cd629dff0f57c8c5b420757f34b7f60a40184617607bdf125025f8"},{"deviceId":"80f28f21743218d1430300452892a9272426095e48d4ddd344bef16a57e2d7cb","kind":"audioinput","label":"마이크(Realtek Audio)","groupId":"2fc5a70356cd629dff0f57c8c5b420757f34b7f60a40184617607bdf125025f8"},{"deviceId":"7fb6410182a2ef6910e68e942dfa9bd4f29350f391599099ed1563ab6e7ac185","kind":"videoinput","label":"Integrated Webcam (0bda:5689)","groupId":"80117ee788b9447605cce20ce90cefec3f387bb62f2df256e2a1559dac667d41"},{"deviceId":"7fb6410182a2ef6910e68e942dfa9bd4f29350f391599099ed1563ab6e7ac185","kind":"videoinput","label":"test Webcam (0bda:5689)","groupId":"80117ee788b9447605cce20ce90cefec3f387bb62f2df256e2a1559dac667d41"}, | |
{"deviceId":"default","kind":"audiooutput","label":"기본값 - 스피커 / 헤드폰(Realtek Audio)","groupId":"2fc5a70356cd629dff0f57c8c5b420757f34b7f60a40184617607bdf125025f8"}, | |
{"deviceId":"communications","kind":"audiooutput","label":"커뮤니케이션 - 스피커 / 헤드폰(Realtek Audio)","groupId":"2fc5a70356cd629dff0f57c8c5b420757f34b7f60a40184617607bdf125025f8"},{"deviceId":"b1ef42095920cde890023686cc26c6792fae6fadcc3e1dc195905097adb3d8a4","kind":"audiooutput","label":"스피커 / 헤드폰(Realtek Audio)","groupId":"2fc5a70356cd629dff0f57c8c5b420757f34b7f60a40184617607bdf125025f8"} | |
]; | |
const newdevices = devices.filter(item => item.kind === 'videoinput').map(item => item.label); | |
console.log(`dev test devices : ${JSON.stringify(newdevices)}`); | |
//dev test devices : ["Integrated Webcam (0bda:5689)","test Webcam (0bda:5689)"] |
Author
sorie
commented
Sep 29, 2021
•
const newdevices = devices.filter(item => item.kind === 'videoinput')
.map(item => item.label);
console.log(`dev test devices : ${JSON.stringify(newdevices)}`);
//dev test devices : ["Integrated Webcam (0bda:5689)","test Webcam (0bda:5689)"]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment