2

I see the below pattern used in JavaScript often.

function (element, options) {
}

Is there a specific name for this pattern? I am looking for advice to use this pattern more efficiently. As of now i am writing code in WinJS but, i have seen this being used on the web as well.

RienNeVaPlu͢s
  • 6,993
  • 6
  • 41
  • 74
Digi
  • 21
  • 4

1 Answers1

3

Using an options parameter in JavaScript is a common pattern, commonly known as the Configuration Object Pattern. It's basically an object literal that provides defaults to configure the behavior of the function/object in question. However, the first paramter in your example, element, appears to be nothing more than a context element that will be acted upon by said method.

Alex
  • 34,121
  • 5
  • 74
  • 88