diff --git a/translations/bn_BN b/translations/bn_BN
new file mode 100644
index 0000000..8ef6b43
--- /dev/null
+++ b/translations/bn_BN
@@ -0,0 +1,1336 @@
+# সামঞ্জস্যপূর্ণ, ইডিওম্যাটিক জাভাস্ক্রিপ্ট লেখার নীতি
+
+
+## এটি একটি রিয়েল নথি এবং আমাদের চারপাশের কোড উন্নত করার জন্য নতুন ধারণাগুলি সর্বদা স্বাগত জানাই ৷ অবদান: fork, clone, branch, commit, push, pull request.
+
+* Rick Waldron [@rwaldron](http://twitter.com/rwaldron), [github](https://github.com/rwaldron)
+* Mathias Bynens [@mathias](http://twitter.com/mathias), [github](https://github.com/mathiasbynens)
+* Schalk Neethling [@ossreleasefeed](http://twitter.com/ossreleasefeed), [github](https://github.com/ossreleasefeed/)
+* Kit Cambridge [@kitcambridge](http://twitter.com/kitcambridge), [github](https://github.com/kitcambridge)
+* Raynos [github](https://github.com/Raynos)
+* Matias Arriola [@MatiasArriola](https://twitter.com/MatiasArriola), [github](https://github.com/MatiasArriola/)
+* John Fischer [@jfroffice](https://twitter.com/jfroffice), [github](https://github.com/jfroffice/)
+* Idan Gazit [@idangazit](http://twitter.com/idangazit), [github](https://github.com/idan)
+* Leo Balter [@leobalter](http://twitter.com/leobalter), [github](https://github.com/leobalter)
+* Breno Oliveira [@garu_rj](http://twitter.com/garu_rj), [github](https://github.com/garu)
+* Leo Beto Souza [@leobetosouza](http://twitter.com/leobetosouza), [github](https://github.com/leobetosouza)
+* Ryuichi Okumura [@okuryu](http://twitter.com/okuryu), [github](https://github.com/okuryu)
+* Pascal Precht [@PascalPrecht](http://twitter.com/PascalPrecht), [github](https://github.com/pascalprecht)
+* EngForDev [engfordev](https://opentutorials.org/course/245/1788) - Hwan Min Hong / MinTaek Kwon [@leoinsight](http://twitter.com/leoinsight) / Tw Shim [@marocchino](http://twitter.com/marocchino), [github](https://github.com/marocchino) / Nassol Kim [@nassol99](http://twitter.com/nassol99), [github](https://github.com/nassol) / Juntai Park [@rkJun](http://twitter.com/rkJun), [github](https://github.com/rkJun) / Minkyu Shim / Gangmin Won / Justin Yoo [@justinchronicle](http://twitter.com/justinchronicle) / Daeyup Lee
+* Marco Trulla [@marcotrulla](http://twitter.com/marcotrulla), [github](https://github.com/Ragnarokkr)
+* Alex Navasardyan [@alexnavasardyan](http://twitter.com/alexnavasardyan), [github](https://github.com/2k00l)
+* Mihai Paun [@mihaipaun](http://twitter.com/mihaipaun), [github](https://github.com/mihaipaun)
+* Evgeny Mandrikov [@\_godin\_](http://twitter.com/_godin_), [github](https://github.com/Godin)
+* Sofish Lin [@sofish](http://twitter.com/sofish), [github](https://github.com/sofish)
+* Дејан Димић [@dejan_dimic](http://twitter.com/dejan_dimic), [github](https://github.com/rubystream)
+* Miloš Gavrilović [@gavrisimo](http://twitter.com/gavrisimo), [github](https://github.com/gavrisimo)
+* Firede [@firede](https://twitter.com/firede) [github](https://github.com/firede)
+* monkadd [github](https://github.com/monkadd)
+* Stephan Lindauer [@stephanlindauer](http://twitter.com/stephanlindauer), [github](https://github.com/stephanlindauer)
+* Thomas P [@dragon5689](https://twitter.com/dragon5689) [github](https://github.com/dragon5689)
+* Yotam Ofek [@yotamofek](https://twitter.com/yotamofek) [github](https://github.com/yotamofek)
+* Aleksandr Filatov [@greybax](http://twitter.com/greybax), [github](https://github.com/greybax)
+* Duc Nguyen [@ducntq](https://twitter.com/ducntq), [github](https://github.com/ducntq)
+* James Young [@jamsyoung](http://twitter.com/jamsyoung), [github](https://github.com/jamsyoung)
+* Hao-Wei Jeng [@l0ckys](http://twitter.com/l0ckys), [github](https://github.com/lockys)
+* Richard Gibson [@gibson042](http://twitter.com/gibson042), [github](https://github.com/gibson042)
+* Fesuy [github](https://github.com/fesuydev)
+* Stephane Moreau [github](https://github.com/stmoreau)
+* Boris Nekezov [github](https://github.com/boris-nekezov)
+* Akshat Joshi [@akshat_joshi](http://twitter.com/akshat_joshi), [github](https://https://github.com/akshatjoshii)
+
+
+## All code in any code-base should look like a single person typed it, no matter how many people contributed.
+
+### The following list outlines the practices that I use in all code that I am the original author of; contributions to projects that I have created should follow these guidelines.
+
+### I do not intend to impose my style preferences on other people's code or projects; if an existing common style exists, it should be respected.
+
+
+> ### "Arguments over style are pointless. There should be a style guide, and you should follow it"
+>_Rebecca_ _Murphey_
+
+
+
+> ### "Part of being a good steward to a successful project is realizing that writing code for yourself is a Bad Idea™. If thousands of people are using your code, then write your code for maximum clarity, not your personal preference of how to get clever within the spec."
+>_Idan_ _Gazit_
+
+
+## Translations
+
+* [Bulgarian](https://github.com/rwldrn/idiomatic.js/tree/master/translations/bg_BG)
+* [German](https://github.com/rwldrn/idiomatic.js/tree/master/translations/de_DE)
+* [French](https://github.com/rwldrn/idiomatic.js/tree/master/translations/fr_FR)
+* [Spanish](https://github.com/rwldrn/idiomatic.js/tree/master/translations/es_ES)
+* [Portuguese - Brazil](https://github.com/rwldrn/idiomatic.js/tree/master/translations/pt_BR)
+* [Korean](https://github.com/rwldrn/idiomatic.js/tree/master/translations/ko_KR)
+* [日本語](https://github.com/rwldrn/idiomatic.js/tree/master/translations/ja_JP)
+* [Italian](https://github.com/rwldrn/idiomatic.js/tree/master/translations/it_IT)
+* [Russian](https://github.com/rwldrn/idiomatic.js/tree/master/translations/ru_RU)
+* [Romanian](https://github.com/rwldrn/idiomatic.js/tree/master/translations/ro_RO)
+* [简体中文](https://github.com/rwldrn/idiomatic.js/tree/master/translations/zh_CN)
+* [Serbian - cyrilic alphabet](https://github.com/rwldrn/idiomatic.js/tree/master/translations/ср_СР)
+* [Serbian - latin alphabet](https://github.com/rwldrn/idiomatic.js/tree/master/translations/sr_SR)
+* [繁體中文](https://github.com/rwaldron/idiomatic.js/tree/master/translations/zh_TW)
+* [Indonesian](https://github.com/rwaldron/idiomatic.js/tree/master/translations/id_ID)
+* [Greek](https://github.com/rwaldron/idiomatic.js/tree/master/translations/gr_GR)
+* [Hindi](https://github.com/rwaldron/idiomatic.js/tree/master/translations/hi_HI)
+
+## Important, Non-Idiomatic Stuff:
+
+### Code Quality Tools, Resources & References
+
+ * [SonarQube](https://www.sonarqube.org/)
+ * [Plato](https://github.com/es-analysis/plato)
+ * [jsPerf](http://jsperf.com/)
+ * [jsFiddle](http://jsfiddle.net/)
+ * [Codepen](http://codepen.io/)
+ * [jsbin](http://jsbin.com/)
+ * [JavaScript Lint (JSL)](http://javascriptlint.com/)
+ * [jshint](http://jshint.com/)
+ * [jslint](http://jslint.org/)
+ * [eslint](http://eslint.org/)
+ * [jscs](https://www.npmjs.org/package/jscs)
+ * [jscodesniffer](https://www.npmjs.org/package/jscodesniffer)
+ * [Editorconfig](http://editorconfig.org/)
+ * [Hound](https://houndci.com/)
+
+## Get Smart
+
+### [Annotated ECMAScript 5.1](http://es5.github.com/)
+### [EcmaScript Language Specification, 5.1 Edition](http://ecma-international.org/ecma-262/5.1/)
+
+The following should be considered 1) incomplete, and 2) *REQUIRED READING*. I don't always agree with the style written by the authors below, but one thing is certain: They are consistent. Furthermore, these are authorities on the language.
+
+ * [Baseline For Front End Developers: 2015](https://rmurphey.com/posts/a-baseline-for-front-end-developers-2015/)
+ * [Eloquent JavaScript](http://eloquentjavascript.net/)
+ * [JavaScript, JavaScript](http://javascriptweblog.wordpress.com/)
+ * [Adventures in JavaScript Development](http://rmurphey.com/)
+ * [Perfection Kills](http://perfectionkills.com/)
+ * [Douglas Crockford's Wrrrld Wide Web](http://www.crockford.com)
+ * [JS Assessment](https://github.com/rmurphey/js-assessment)
+
+
+
+
+### Build & Deployment Process
+
+Projects should always attempt to include some generic means by which source can be linted, tested and compressed in preparation for production use. For this task, [grunt](https://github.com/gruntjs/grunt) by Ben Alman is second to none and has officially replaced the "kits/" directory of this repo.
+
+
+
+
+### Test Facility
+
+Projects _must_ include some form of unit, reference, implementation or functional testing. Use case demos DO NOT QUALIFY as "tests". The following is a list of test frameworks, none of which are endorsed more than the other.
+
+ * [QUnit](http://github.com/jquery/qunit)
+ * [Jasmine](https://github.com/pivotal/jasmine)
+ * [Vows](https://github.com/cloudhead/vows)
+ * [Mocha](https://github.com/visionmedia/mocha)
+ * [Hiro](http://hirojs.com/)
+ * [JsTestDriver](https://code.google.com/p/js-test-driver/)
+ * [Buster.js](http://busterjs.org/)
+ * [Sinon.js](http://sinonjs.org/)
+ * [Tape](https://github.com/substack/tape)
+ * [Jest](https://facebook.github.io/jest/)
+
+## Table of Contents
+
+ * [Whitespace](#whitespace)
+ * [Beautiful Syntax](#spacing)
+ * [Type Checking (Courtesy jQuery Core Style Guidelines)](#type)
+ * [Conditional Evaluation](#cond)
+ * [Practical Style](#practical)
+ * [Naming](#naming)
+ * [Misc](#misc)
+ * [Native & Host Objects](#native)
+ * [Comments](#comments)
+ * [One Language Code](#language)
+
+
+
+------------------------------------------------
+
+
+## Preface
+
+The following sections outline a _reasonable_ style guide for modern JavaScript development and are not meant to be prescriptive. The most important take-away is the **law of code style consistency**. Whatever you choose as the style for your project should be considered law. Link to this document as a statement of your project's commitment to code style consistency, readability and maintainability.
+
+
+
+
+
+## Idiomatic Style Manifesto
+
+
+1. Whitespace
+ - Never mix spaces and tabs.
+ - When beginning a project, before you write any code, choose between soft indents (spaces) or real tabs, consider this **law**.
+ - For readability, I always recommend setting your editor's indent size to two characters — this means two spaces or two spaces representing a real tab.
+ - If your editor supports it, always work with the "show invisibles" setting turned on. The benefits of this practice are:
+ - Enforced consistency
+ - Eliminating end of line whitespace
+ - Eliminating blank line whitespace
+ - Commits and diffs that are easier to read
+ - Use [Editorconfig](http://editorconfig.org/) when possible. It supports most IDEs and handles most whitespace settings.
+
+
+2. Beautiful Syntax
+
+ A. Parens, Braces, Linebreaks
+
+ ```javascript
+
+ // if/else/for/while/try always have spaces, braces and span multiple lines
+ // this encourages readability
+
+ // 2.A.1.1
+ // Examples of really cramped syntax
+
+ if(condition) doSomething();
+
+ while(condition) iterating++;
+
+ for(var i=0;i<100;i++) someIterativeFn();
+
+
+ // 2.A.1.1
+ // Use whitespace to promote readability
+
+ if ( condition ) {
+ // statements
+ }
+
+ while ( condition ) {
+ // statements
+ }
+
+ for ( var i = 0; i < 100; i++ ) {
+ // statements
+ }
+
+ // Even better:
+
+ var i,
+ length = 100;
+
+ for ( i = 0; i < length; i++ ) {
+ // statements
+ }
+
+ // Or...
+
+ var i = 0,
+ length = 100;
+
+ for ( ; i < length; i++ ) {
+ // statements
+ }
+
+ var prop;
+
+ for ( prop in object ) {
+ // statements
+ }
+
+
+ if ( true ) {
+ // statements
+ } else {
+ // statements
+ }
+ ```
+
+
+ B. Assignments, Declarations, Functions ( Named, Expression, Constructor )
+
+ ```javascript
+
+ // 2.B.1.1
+ // Variables
+ var foo = "bar",
+ num = 1,
+ undef;
+
+ // Literal notations:
+ var array = [],
+ object = {};
+
+
+ // 2.B.1.2
+ // Using only one `var` per scope (function) or one `var` for each variable,
+ // promotes readability and keeps your declaration list free of clutter.
+ // Using one `var` per variable you can take more control of your versions
+ // and makes it easier to reorder the lines.
+ // One `var` per scope makes it easier to detect undeclared variables
+ // that may become implied globals.
+ // Choose better for your project and never mix them.
+
+ // Bad
+ var foo = "",
+ bar = "";
+ var qux;
+
+ // Good
+ var foo = "";
+ var bar = "";
+ var qux;
+
+ // or..
+ var foo = "",
+ bar = "",
+ qux;
+
+ // or..
+ var // Comment on these
+ foo = "",
+ bar = "",
+ quux;
+
+ // 2.B.1.3
+ // var statements should always be in the beginning of their respective scope (function).
+
+
+ // Bad
+ function foo() {
+
+ // some statements here
+
+ var bar = "",
+ qux;
+ }
+
+ // Good
+ function foo() {
+ var bar = "",
+ qux;
+
+ // all statements after the variables declarations.
+ }
+
+ // 2.B.1.4
+ // const and let, from ECMAScript 6, should likewise be at the top of their scope (block).
+
+ // Bad
+ function foo() {
+ let foo,
+ bar;
+ if ( condition ) {
+ bar = "";
+ // statements
+ }
+ }
+ // Good
+ function foo() {
+ let foo;
+ if ( condition ) {
+ let bar = "";
+ // statements
+ }
+ }
+ ```
+
+ ```javascript
+
+ // 2.B.2.1
+ // Named Function Declaration
+ function foo( arg1, argN ) {
+
+ }
+
+ // Usage
+ foo( arg1, argN );
+
+
+ // 2.B.2.2
+ // Named Function Declaration
+ function square( number ) {
+ return number * number;
+ }
+
+ // Usage
+ square( 10 );
+
+ // Really contrived continuation passing style
+ function square( number, callback ) {
+ callback( number * number );
+ }
+
+ square( 10, function( square ) {
+ // callback statements
+ });
+
+
+ // 2.B.2.3
+ // Function Expression
+ var square = function( number ) {
+ // Return something valuable and relevant
+ return number * number;
+ };
+
+ // Function Expression with Identifier
+ // This preferred form has the added value of being
+ // able to call itself and have an identity in stack traces:
+ var factorial = function factorial( number ) {
+ if ( number < 2 ) {
+ return 1;
+ }
+
+ return number * factorial( number - 1 );
+ };
+
+
+ // 2.B.2.4
+ // Constructor Declaration
+ function FooBar( options ) {
+
+ this.options = options;
+ }
+
+ // Usage
+ var fooBar = new FooBar({ a: "alpha" });
+
+ fooBar.options;
+ // { a: "alpha" }
+
+ ```
+
+
+ C. Exceptions, Slight Deviations
+
+ ```javascript
+
+ // 2.C.1.1
+ // Functions with callbacks
+ foo(function() {
+ // Note there is no extra space between the first paren
+ // of the executing function call and the word "function"
+ });
+
+ // Function accepting an array, no space
+ foo([ "alpha", "beta" ]);
+
+ // 2.C.1.2
+ // Function accepting an object, no space
+ foo({
+ a: "alpha",
+ b: "beta"
+ });
+
+ // Single argument string literal, no space
+ foo("bar");
+
+ // Expression parens, no space
+ if ( !("foo" in obj) ) {
+ obj = (obj.bar || defaults).baz;
+ }
+
+ ```
+
+ D. Consistency Always Wins
+
+ In sections 2.A-2.C, the whitespace rules are set forth as a recommendation with a simpler, higher purpose: consistency.
+ It's important to note that formatting preferences, such as "inner whitespace" should be considered optional, but only one style should exist across the entire source of your project.
+
+ ```javascript
+
+ // 2.D.1.1
+
+ if (condition) {
+ // statements
+ }
+
+ while (condition) {
+ // statements
+ }
+
+ for (var i = 0; i < 100; i++) {
+ // statements
+ }
+
+ if (true) {
+ // statements
+ } else {
+ // statements
+ }
+
+ ```
+
+ E. Quotes
+
+ Whether you prefer single or double shouldn't matter, there is no difference in how JavaScript parses them. What **ABSOLUTELY MUST** be enforced is consistency. **Never mix quotes in the same project. Pick one style and stick with it.**
+
+ F. End of Lines and Empty Lines
+
+ Whitespace can ruin diffs and make changesets impossible to read. Consider incorporating a pre-commit hook that removes end-of-line whitespace and blanks spaces on empty lines automatically.
+
+3. Type Checking (Courtesy jQuery Core Style Guidelines)
+
+ A. Actual Types
+
+ String:
+
+ typeof variable === "string"
+
+ Number:
+
+ typeof variable === "number"
+
+ Boolean:
+
+ typeof variable === "boolean"
+
+ Object:
+
+ typeof variable === "object"
+
+ Array:
+
+ Array.isArray( arrayLikeObject )
+ (wherever possible)
+
+ Node:
+
+ elem.nodeType === 1
+
+ null:
+
+ variable === null
+
+ null or undefined:
+
+ variable == null
+
+ undefined:
+
+ Global Variables:
+
+ typeof variable === "undefined"
+
+ Local Variables:
+
+ variable === undefined
+
+ Properties:
+
+ object.prop === undefined
+ object.hasOwnProperty( prop )
+ "prop" in object
+
+ B. Coerced Types
+
+ Consider the implications of the following...
+
+ Given this HTML:
+
+ ```html
+
+
+
+ ```
+
+
+ ```javascript
+
+ // 3.B.1.1
+
+ // `foo` has been declared with the value `0` and its type is `number`
+ var foo = 0;
+
+ // typeof foo;
+ // "number"
+ ...
+
+ // Somewhere later in your code, you need to update `foo`
+ // with a new value derived from an input element
+
+ foo = document.getElementById("foo-input").value;
+
+ // If you were to test `typeof foo` now, the result would be `string`
+ // This means that if you had logic that tested `foo` like:
+
+ if ( foo === 1 ) {
+
+ importantTask();
+
+ }
+
+ // `importantTask()` would never be evaluated, even though `foo` has a value of "1"
+
+
+ // 3.B.1.2
+
+ // You can preempt issues by using smart coercion with unary + or - operators:
+
+ foo = +document.getElementById("foo-input").value;
+ // ^ unary + operator will convert its right side operand to a number
+
+ // typeof foo;
+ // "number"
+
+ if ( foo === 1 ) {
+
+ importantTask();
+
+ }
+
+ // `importantTask()` will be called
+ ```
+
+ Here are some common cases along with coercions:
+
+
+ ```javascript
+
+ // 3.B.2.1
+
+ var number = 1,
+ string = "1",
+ bool = false;
+
+ number;
+ // 1
+
+ number + "";
+ // "1"
+
+ string;
+ // "1"
+
+ +string;
+ // 1
+
+ +string++;
+ // 1
+
+ string;
+ // 2
+
+ bool;
+ // false
+
+ +bool;
+ // 0
+
+ bool + "";
+ // "false"
+ ```
+
+
+ ```javascript
+ // 3.B.2.2
+
+ var number = 1,
+ string = "1",
+ bool = true;
+
+ string === number;
+ // false
+
+ string === number + "";
+ // true
+
+ +string === number;
+ // true
+
+ bool === number;
+ // false
+
+ +bool === number;
+ // true
+
+ bool === string;
+ // false
+
+ bool === !!string;
+ // true
+ ```
+
+ ```javascript
+ // 3.B.2.3
+
+ var array = [ "a", "b", "c" ];
+
+ !!~array.indexOf("a");
+ // true
+
+ !!~array.indexOf("b");
+ // true
+
+ !!~array.indexOf("c");
+ // true
+
+ !!~array.indexOf("d");
+ // false
+
+ // Note that the above should be considered "unnecessarily clever"
+ // Prefer the obvious approach of comparing the returned value of
+ // indexOf, like:
+
+ if ( array.indexOf( "a" ) >= 0 ) {
+ // ...
+ }
+ ```
+
+ ```javascript
+ // 3.B.2.4
+
+
+ var num = 2.5;
+
+ parseInt( num, 10 );
+
+ // is the same as...
+
+ ~~num;
+
+ num >> 0;
+
+ num >>> 0;
+
+ // All result in 2
+
+
+ // Keep in mind however, that negative numbers will be treated differently...
+
+ var neg = -2.5;
+
+ parseInt( neg, 10 );
+
+ // is the same as...
+
+ ~~neg;
+
+ neg >> 0;
+
+ // All result in -2
+ // However...
+
+ neg >>> 0;
+
+ // Will result in 4294967294
+
+
+
+
+ ```
+
+
+
+4. Conditional Evaluation
+
+ ```javascript
+
+ // 4.1.1
+ // When only evaluating that an array has length,
+ // instead of this:
+ if ( array.length > 0 ) ...
+
+ // ...evaluate truthiness, like this:
+ if ( array.length ) ...
+
+
+ // 4.1.2
+ // When only evaluating that an array is empty,
+ // instead of this:
+ if ( array.length === 0 ) ...
+
+ // ...evaluate truthiness, like this:
+ if ( !array.length ) ...
+
+
+ // 4.1.3
+ // When only evaluating that a string is not empty,
+ // instead of this:
+ if ( string !== "" ) ...
+
+ // ...evaluate truthiness, like this:
+ if ( string ) ...
+
+
+ // 4.1.4
+ // When only evaluating that a string _is_ empty,
+ // instead of this:
+ if ( string === "" ) ...
+
+ // ...evaluate falsy-ness, like this:
+ if ( !string ) ...
+
+
+ // 4.1.5
+ // When only evaluating that a reference is true,
+ // instead of this:
+ if ( foo === true ) ...
+
+ // ...evaluate like you mean it, take advantage of built in capabilities:
+ if ( foo ) ...
+
+
+ // 4.1.6
+ // When evaluating that a reference is false,
+ // instead of this:
+ if ( foo === false ) ...
+
+ // ...use negation to coerce a true evaluation
+ if ( !foo ) ...
+
+ // ...Be careful, this will also match: 0, "", null, undefined, NaN
+ // If you _MUST_ test for a boolean false, then use
+ if ( foo === false ) ...
+
+
+ // 4.1.7
+ // When only evaluating a ref that might be null or undefined, but NOT false, "" or 0,
+ // instead of this:
+ if ( foo === null || foo === undefined ) ...
+
+ // ...take advantage of == type coercion, like this:
+ if ( foo == null ) ...
+
+ // Remember, using == will match a `null` to BOTH `null` and `undefined`
+ // but not `false`, "" or 0
+ null == undefined
+
+ ```
+ ALWAYS evaluate for the best, most accurate result - the above is a guideline, not a dogma.
+
+ ```javascript
+
+ // 4.2.1
+ // Type coercion and evaluation notes
+
+ // Prefer `===` over `==` (unless the case requires loose type evaluation)
+
+ // === does not coerce type, which means that:
+
+ "1" === 1;
+ // false
+
+ // == does coerce type, which means that:
+
+ "1" == 1;
+ // true
+
+
+ // 4.2.2
+ // Booleans, Truthies & Falsies
+
+ // Booleans:
+ true, false
+
+ // Truthy:
+ "foo", 1
+
+ // Falsy:
+ "", 0, null, undefined, NaN, void 0
+
+ ```
+
+
+5. Practical Style
+
+ ```javascript
+
+ // 5.1.1
+ // A Practical Module
+
+ (function( global ) {
+ var Module = (function() {
+
+ var data = "secret";
+
+ return {
+ // This is some boolean property
+ bool: true,
+ // Some string value
+ string: "a string",
+ // An array property
+ array: [ 1, 2, 3, 4 ],
+ // An object property
+ object: {
+ lang: "en-Us"
+ },
+ getData: function() {
+ // get the current value of `data`
+ return data;
+ },
+ setData: function( value ) {
+ // set the value of `data` and return it
+ return ( data = value );
+ }
+ };
+ })();
+
+ // Other things might happen here
+
+ // expose our module to the global object
+ global.Module = Module;
+
+ })( this );
+
+ ```
+
+ ```javascript
+
+ // 5.2.1
+ // A Practical Constructor
+
+ (function( global ) {
+
+ function Ctor( foo ) {
+
+ this.foo = foo;
+
+ return this;
+ }
+
+ Ctor.prototype.getFoo = function() {
+ return this.foo;
+ };
+
+ Ctor.prototype.setFoo = function( val ) {
+ return ( this.foo = val );
+ };
+
+
+ // To call constructor's without `new`, you might do this:
+ var ctor = function( foo ) {
+ return new Ctor( foo );
+ };
+
+
+ // expose our constructor to the global object
+ global.ctor = ctor;
+
+ })( this );
+
+ ```
+
+
+
+6. Naming
+
+
+
+ A. You are not a human code compiler/compressor, so don't try to be one.
+
+ The following code is an example of egregious naming:
+
+ ```javascript
+
+ // 6.A.1.1
+ // Example of code with poor names
+
+ function q(s) {
+ return document.querySelectorAll(s);
+ }
+ var i,a=[],els=q("#foo");
+ for(i=0;iMisc
+
+ This section will serve to illustrate ideas and concepts that should not be considered dogma, but instead exists to encourage questioning practices in an attempt to find better ways to do common JavaScript programming tasks.
+
+ A. Using `switch` should be avoided, modern method tracing will blacklist functions with switch statements
+
+ There seems to be drastic improvements to the execution of `switch` statements in latest releases of Firefox and Chrome.
+ http://jsperf.com/switch-vs-object-literal-vs-module
+
+ Notable improvements can be witnessed here as well:
+ https://github.com/rwldrn/idiomatic.js/issues/13
+
+ ```javascript
+
+ // 7.A.1.1
+ // An example switch statement
+
+ switch( foo ) {
+ case "alpha":
+ alpha();
+ break;
+ case "beta":
+ beta();
+ break;
+ default:
+ // something to default to
+ break;
+ }
+
+ // 7.A.1.2
+ // A alternate approach that supports composability and reusability is to
+ // use an object to store "cases" and a function to delegate:
+
+ var cases, delegator;
+
+ // Example returns for illustration only.
+ cases = {
+ alpha: function() {
+ // statements
+ // a return
+ return [ "Alpha", arguments.length ];
+ },
+ beta: function() {
+ // statements
+ // a return
+ return [ "Beta", arguments.length ];
+ },
+ _default: function() {
+ // statements
+ // a return
+ return [ "Default", arguments.length ];
+ }
+ };
+
+ delegator = function() {
+ var args, key, delegate;
+
+ // Transform arguments list into an array
+ args = [].slice.call( arguments );
+
+ // shift the case key from the arguments
+ key = args.shift();
+
+ // Assign the default case handler
+ delegate = cases._default;
+
+ // Derive the method to delegate operation to
+ if ( cases.hasOwnProperty( key ) ) {
+ delegate = cases[ key ];
+ }
+
+ // The scope arg could be set to something specific,
+ // in this case, |null| will suffice
+ return delegate.apply( null, args );
+ };
+
+ // 7.A.1.3
+ // Put the API in 7.A.1.2 to work:
+
+ delegator( "alpha", 1, 2, 3, 4, 5 );
+ // [ "Alpha", 5 ]
+
+ // Of course, the `case` key argument could easily be based
+ // on some other arbitrary condition.
+
+ var caseKey, someUserInput;
+
+ // Possibly some kind of form input?
+ someUserInput = 9;
+
+ if ( someUserInput > 10 ) {
+ caseKey = "alpha";
+ } else {
+ caseKey = "beta";
+ }
+
+ // or...
+
+ caseKey = someUserInput > 10 ? "alpha" : "beta";
+
+ // And then...
+
+ delegator( caseKey, someUserInput );
+ // [ "Beta", 1 ]
+
+ // And of course...
+
+ delegator();
+ // [ "Default", 0 ]
+
+
+ ```
+
+ B. Early returns promote code readability with negligible performance difference
+
+ ```javascript
+
+ // 7.B.1.1
+ // Bad:
+ function returnLate( foo ) {
+ var ret;
+
+ if ( foo ) {
+ ret = "foo";
+ } else {
+ ret = "quux";
+ }
+ return ret;
+ }
+
+ // Good:
+
+ function returnEarly( foo ) {
+
+ if ( foo ) {
+ return "foo";
+ }
+ return "quux";
+ }
+
+ ```
+
+
+8. Native & Host Objects
+
+ The basic principle here is:
+
+ ### Don't do stupid shit and everything will be ok.
+
+ To reinforce this concept, please watch the following presentation:
+
+ #### “Everything is Permitted: Extending Built-ins” by Andrew Dupont (JSConf2011, Portland, Oregon)
+
+ https://www.youtube.com/watch?v=xL3xCO7CLNM
+
+
+9. Comments
+
+ #### Single line above the code that is subject
+ #### Multiline is good
+ #### End of line comments are prohibited!
+ #### JSDoc style is good, but requires a significant time investment
+
+
+10. One Language Code
+
+ Programs should be written in one language, whatever that language may be, as dictated by the maintainer or maintainers.
+
+## Appendix
+
+### Comma First.
+
+Any project that cites this document as its base style guide will not accept comma first code formatting, unless explicitly specified otherwise by that project's author.
+
+
+
+----------
+
+
+ Principles of Writing Consistent, Idiomatic JavaScript by Rick Waldron and Contributors is licensed under a Creative Commons Attribution 3.0 Unported License. Based on a work at github.com/rwldrn/idiomatic.js.