Last active
September 26, 2023 07:45
Revisions
-
sindresorhus revised this gist
Feb 13, 2014 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,6 @@ - Semicolon - Strict mode - No trailing whitespace - Multiple variable statements - Space after keywords and between arguments and operators - Return early @@ -18,14 +17,14 @@ Example: 'use strict'; function foo(bar, fum) { var ret; var hello = 'Hello'; if (!bar) { return; } for (var i = 0; i < bar.length; i++) { if (bar[i] === hello) { ret += fum(bar[i]); } -
sindresorhus revised this gist
Dec 12, 2012 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,9 @@ ## Code Style - Tab indentation - Single-quotes - Semicolon - Strict mode - No trailing whitespace - Variables at the top of the scope - Multiple variable statements @@ -14,6 +15,8 @@ Example: ```js 'use strict'; function foo(bar, fum) { var i, l, ret; var hello = 'Hello'; @@ -24,7 +27,7 @@ function foo(bar, fum) { for (i = 0, l = bar.length; i < l; i++) { if (bar[i] === hello) { ret += fum(bar[i]); } } -
sindresorhus created this gist
Dec 12, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ # Code Style - Tab indentation - Single-quotes - Semicolon - No trailing whitespace - Variables at the top of the scope - Multiple variable statements - Space after keywords and between arguments and operators - Return early - JSHint valid - Consistency Example: ```js function foo(bar, fum) { var i, l, ret; var hello = 'Hello'; if (!bar) { return; } for (i = 0, l = bar.length; i < l; i++) { if (bar[i] === hello) { ret = fum(out); } } return ret; } ``` Read [idiomatic.js](https://github.com/rwldrn/idiomatic.js) for general JavaScript code style best practices.