3

I have a lot of .on() methods that I'd like to chain and align. I'm afraid that the interpreter might insert a semicolon after a variable name in this example:

var foo = new Bar();

foo // Semicolon insertion here.
  .on()
  .on();

Is there a way to keep this structure, or should I avoid doing it? Thank you!

awgv
  • 280
  • 4
  • 23

1 Answers1

11

Semi-colons are not inserted on lines preceding a line that starts with a .

You can safely start method / property chaining on new lines.

objectName
    .method1()
    .property
    .method2();
TbWill4321
  • 8,626
  • 3
  • 27
  • 25