1

Why does this not work? I get an error that this action is not supported by my IE9.

var data = new { selectedUnitKey: { value1: 1, value2: 2} }

1 Answer 1

3

Remove the new :

var data = { selectedUnitKey: { value1: 1, value2: 2} }

From the MDN :

The new operator creates an instance of a user-defined object type or of one of the built-in object types that has a constructor function.

You use new like this when you define your "class" :

function SomeClass(unitKey) {
     this.selectedUnitKey = unitKey;
}
var data = new SomeClass({ value1: 1, value2: 2});
Sign up to request clarification or add additional context in comments.

1 Comment

ah... I got confused with the c# anonym objects... Thanks man.

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.