From 2e51880f1046ce7673167f34b02afe7c7e17bb51 Mon Sep 17 00:00:00 2001 From: Tomek Wiszniewski Date: Thu, 2 Apr 2015 04:10:21 +0200 Subject: [PATCH] Specify whitespace rules for parentheses Based on existing examples and . --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index bcbe6489..c395491c 100644 --- a/README.md +++ b/README.md @@ -803,6 +803,30 @@ }); ``` + - Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space before the argument list in function calls and declarations. + + ```javascript + // bad + if(isJedi) { + fight (); + } + + // good + if (isJedi) { + fight(); + } + + // bad + function fight () { + console.log ('Swooosh!'); + } + + // good + function fight() { + console.log('Swooosh!'); + } + ``` + - Set off operators with spaces. ```javascript