Is it safe to split long JavaScript if conditions into multiple lines?

Browsers are very forgiving when it comes to whitespace and line breaks in conditionals. You can honestly get away with a lot of things (for better or worse haha). Right now these two formats are the industry standard. Personally, I like the syntax in the second syntax more.

Syntax A

if (
  a === 123 &&
  b === 'abc'
) { ... }

Syntax B

if (
  a === 123
  && b === 'abc'
) { ... }

AirBnb’s preferred syntax: https://github.com/airbnb/javascript/issues/1380

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)