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.

1
  • 1
    You might want to read these answers Commented May 21, 2014 at 17:48

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.