Reputation: 1238
OK. I need to document some product, which is in JS, but I'm a little clumsy with the languge. There are code blocks in the documentation and I need to break some lines (they have huge tails in PDF). In Python I can do the following:
foo(bar1,
bar2)
Can I do so in JavaScript? What are general recommendations on breaking long lines in JS?
Upvotes: 0
Views: 696
Reputation: 5115
You could do that with JavaScript. Like Python, JavaScript will understand the brackets. I personally recommend writing comments before or after a method, not within its definition. If you give your comments their own space, your code will become quite clear, however adding the comments inline can be quite messy.
Upvotes: 0
Reputation: 117971
Yes you may use line breaks with commas as you have written. Here is an example from the Google JavaScript Style Guide.
// Parenthesis-aligned, one argument per line. Emphasizes each
// individual argument.
function bar(veryDescriptiveArgumentNumberOne,
veryDescriptiveArgumentTwo,
tableModelEventHandlerProxy,
artichokeDescriptorAdapterIterator) {
// ...
}
Upvotes: 2