Documentation Suggestion: Remove quotes from keys in javascript object
Documentation Suggestion: Remove quotes from keys in javascript object
tacman1123
Posts: 199Questions: 46Answers: 1
Loving the new Datatables 1.8, playing with the Scroller now, will probably adopt site-wide soon.
Would you consider changing your documentation style to not quote the object keys? I think it improves readability -- it's a tiny thing, but wanted to propose it anyway. Here's the difference:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"sAjaxSource": "media/dataset/large.txt",
"sDom": "frtiS",
"bDeferRender": true
} );
} );
[/code]
Without quoting the keys:
[code]
$(document).ready(function() {
$('#example').dataTable( {
sScrollY: "200px",
sAjaxSource: "media/dataset/large.txt",
sDom: "frtiS",
bDeferRender: true
} );
} );
[/code]
Just a thought.
Tac
Would you consider changing your documentation style to not quote the object keys? I think it improves readability -- it's a tiny thing, but wanted to propose it anyway. Here's the difference:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"sAjaxSource": "media/dataset/large.txt",
"sDom": "frtiS",
"bDeferRender": true
} );
} );
[/code]
Without quoting the keys:
[code]
$(document).ready(function() {
$('#example').dataTable( {
sScrollY: "200px",
sAjaxSource: "media/dataset/large.txt",
sDom: "frtiS",
bDeferRender: true
} );
} );
[/code]
Just a thought.
Tac
This discussion has been closed.
Replies
[code]
var a = 123;
var b = {
a: 456
};
[/code]
In the above is the 'a' in the 'b' object a string literal or 123? It is of course just 'a', but personally I find that a bit odd and possibly confusing.
Generally I try to align Javascript objects:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"sAjaxSource": "media/dataset/large.txt",
"sDom": "frtiS",
"bDeferRender": true
} );
} );
// or
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"sAjaxSource": "media/dataset/large.txt",
"sDom": "frtiS",
"bDeferRender": true
} );
} );
[/code]
but I've obviously been a bit lax in places :-(. Readable documentation is what is wanted though (given that I use it a lot myself, I want that too!) so I'll look at how this can be improved.
Thanks for the feedback!
Allan
Documentation Suggestion: Remove quotes from keys in Javascript object
While I understand your logic, I still prefer to see js objects without quotes, it looks better in the formatted js in this forum, and it feels more "right" to me -- "abc": "def" to me looks like a pair of strings, where abc: "def", has the feel of assignment.
Anyway, my two cents, thanks for listening!
Tac
Regards,
Allan