Created
January 4, 2013 09:41
-
-
Save makeusabrew/4451255 to your computer and use it in GitHub Desktop.
Various object key / val alignment styles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1) colon aligned, no spaces where possible | |
var Foo = { | |
host :"foo", | |
db :"bar", | |
details:"baz" | |
}; | |
// 2) colon aligned, space after key | |
var Foo = { | |
host : "foo", | |
db : "bar", | |
details: "baz" | |
}; | |
// 3) colon aligned, space before & after key | |
var Foo = { | |
host : "foo", | |
db : "bar", | |
details : "baz" | |
}; | |
// 4) space aligned, no spaces where possible | |
var Foo = { | |
host: "foo", | |
db: "bar", | |
details:"baz" | |
}; | |
// 5) space aligned, space after key | |
var Foo = { | |
host: "foo", | |
db: "bar", | |
details: "baz" | |
}; | |
// 6) space aligned, space before & after key | |
var Foo = { | |
host : "foo", | |
db : "bar", | |
details : "baz" | |
}; | |
// or something else entirely? |
Wow, this is 4-year-old thread. But this how I align things.
Right align keys on colon. Values left aligned with space after colon.
{
key: 1,
string: "value",
object_key: {
string_key: "string",
integer_key: 2
},
function_key: () => {
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@davedevelopment Ewww.