Each line in JS that declares variables should have its own var keyword, in order for diffs to not change irrelevant lines.
See also: http://benalman.com/news/2012/05/multip ... avascript/

var obj = {};
obj.foo = 'a';
obj.bar = 'b';var ary = [];
ary.push('a');
ary.push('b');var foo, bar;
foo = 1;
bar = 2;
callumacrae wrote:What I wouldn't be against is the change suggested at the end of the article:
- Code: Select all
var foo, bar;
foo = 1;
bar = 2;
callumacrae wrote:I also suggest that in the name of a nicer diff, we use the following syntax for objects:
- Code: Select all
var obj = {};
obj.foo = 'a';
obj.bar = 'b';
In fact, pretty much all of the relevant arguments can be applied to objects.
Let's take it a step further. I reckon that we should use the following for arrays:
- Code: Select all
var ary = [];
ary.push('a');
ary.push('b');
It's only a few extra characters, and it makes it way easier to reorder array entries, no?
(function() {
var obj = {};
obj.foo = 'a';
obj.bar = 'b';
var ary = [];
ary.push('a');
ary.push('b');
})()(function(){var a={};a.foo="a",a.bar="b";var b=[];b.push("a"),b.push("b")})()(function() {
var obj = {
'foo' : 'a',
'bar' : 'b'
};
var ary = [
'a',
'b'
];
})()(function(){var a={foo:"a",bar:"b"},b=["a","b"]})()callumacrae wrote:What I wouldn't be against is the change suggested at the end of the article:
- Code: Select all
var foo, bar;
foo = 1;
bar = 2;



callumacrae wrote:to demonstrate the absurdity of what you're requesting

Users browsing this forum: imkingdavid and 13 guests