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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.