From 10becbaab08ae1d2743eb065d4b1ef5dcbd9d64d Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Tue, 15 Mar 2016 12:22:53 +0200 Subject: [PATCH] (Coding Convention) Use stacked `else/catch` clauses. --- CodingConvention.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CodingConvention.md b/CodingConvention.md index 0a13d2935..e8ad064b7 100644 --- a/CodingConvention.md +++ b/CodingConvention.md @@ -87,6 +87,29 @@ if (true) Also, notice the use of whitespace before and after the condition statement. +Follow the JavaScript convention of stacking `else/catch` clauses on the same line as the previous closing brace. + +*Right:* + +~~~ {.javascript} +if (i % 2 === 0) { + console.log('even'); +} else { + console.log('odd'); +} +~~~ + +*Wrong:* + +~~~ {.javascript} +if (i % 2 === 0) { + console.log('even'); +} +else { + console.log('odd'); +} +~~~ + ## Variable declarations Declare one variable per var statement. Try to put those declarations at the beginning of each scope.