Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript object array initializer formatting

My IDE is visual studio 2015 with Resharper 9.2, I want the javascript object array initializer automatically formated like this

var  x = [{
   a: 1,
   b: 2 
},{
   a: 3,
   b: 4 
}];

I want the round and square brackets together, Any ideas how can i do this?

It is always formatted like this:

var  x = [
    {
       a: 1,
       b: 2 
    },{
       a: 3,
       b: 4 
    }
];
like image 252
www.diwatu.com Avatar asked May 29 '15 20:05

www.diwatu.com


People also ask

How do you initialize an object in JavaScript?

Objects can be initialized using new Object() , Object. create() , or using the literal notation (initializer notation). An object initializer is a comma-delimited list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ( {} ).

What is the correct syntax for declaring an object literal?

Declaring methods and properties using Object Literal syntax The Object literal notation is basically an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last, just like a regular array.

Can you have an array of objects in JavaScript?

JavaScript variables can be objects. Arrays are special kinds of objects. Because of this, you can have variables of different types in the same Array.


1 Answers

You can change the formatting rules of VS as explained here. The problem should be solved by selecting either block or smart.

like image 112
Tom Doodler Avatar answered Oct 21 '22 13:10

Tom Doodler