Last active
September 4, 2018 07:40
-
-
Save thehunmonkgroup/1e687259167e3a48a55cd0f3260deb70 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
/** | |
* Illustrates methods for testing for the existence of support | |
* for setting a speaker device. | |
*/ | |
// Check for the setSinkId() method on HTMLMediaElement. | |
if (setSinkId in HTMLMediaElement.prototype) { | |
// Do the work. | |
} | |
// ...or... | |
// Check for the sinkId property on an HTMLMediaElement instance. | |
if (typeof element.sinkId !== 'undefined') { | |
// Do the work. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if ('setSinkId' in HTMLMediaElement.prototype)
(missing quotes) is the better check in terms of semantics as it checks for general support)