Create your blog and photo album with postbit
Create your blog and photo album

Create new post

Content:

Upload a picture:
Tags (keywords separated by comma)

Save Cancel
The JavaScript Blog js:   Followers: 3 ; Following: 3

Explore The JavaScript Blog's photo albums:
Javascript tools (2)
Photos from posts (7)

JavaScript Style Guide


Principles of Writing Consistent, Idiomatic JavaScript
 
JavaScript Style Guide: https://github.com/rwaldron/idiomatic.js
 
Idiomatic Style Manifesto, Whitespace, Beautiful Syntax, Type Checking (Courtesy jQuery Core Style Guidelines), Conditional Evaluation, Practical Style (example of Module and Constructor) , Naming, Misc (example of switch statement, cases-delegator pattern)
 
Example of sample JavaScript code to create a constructor:
 
// 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 );

Post by The JavaScript Blog (2013-09-09 12:12)

Post your comment:

Name: Email: Site:




| Explore users | New posts | Create your blog | Create your photo album |
| About Postbit | Our blog | Terms of use | Contact Postbit |


Copyright © 2017 - postbit.com