From this article I found a strange syntax for passing parameter as navigator.getUserMedia({video: true, audio: true}, ...). What is this syntax of passing parameter as {video: true, audio: true} called?
While this syntax navigator.getUserMedia("audio, video", ...) also works, which one should we prefer?
I found the question on StackOverflow but the answer accepted there says its an ActionScript syntax.
The syntax
{...}is creating an object literal. In this case, they happen to be constructing the object literal as a parameter.This is similar to executing a function and passing it’s return value as a parameter:
The benefits of passing an object literal is that it allows you to pass multiple logically related arguments together as one formal parameter. This allows dynamic arguments, which could also be achieved by using the
argumentsobject, though most people prefer passing objects as it is easier to understand and maintain.