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
  • 7,442
  • 6
  • 43
  • 77
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,899
  • 5
  • 77
  • 90