Anthanh PRO
I ♥ the web, technologies and....beers! Co-founder of https://etereo.io
Programa con ESTILO!
"All code in any code-base should look like a single person typed it, no matter how many people contributed.
Rick Waldron"
if ( condition ) {
// statements
}
while ( condition ) {
// statements
}
for ( var i = 0; i < 100; i++ ) {
// statements
}
// Variables
var foo = "bar",
num = 1,
undef;
// Literal notations:
var array = [],
object = {};
// Bad
function foo() {
// some statements here
var bar = "",
qux;
}
// Good
function foo() {
var bar = "",
qux;
// all statements after the variables declarations.
}
// Named Function Declaration
function foo( arg1, argN ) {
// some statements here
}
// Usage
foo( arg1, argN );
// Function Expression
var square = function( number ) {
// Return something valuable and relevant
return number * number;
};
// Usage
square( 4 );
foo(function() {
// Note there is no extra space between the first paren
// of the executing function call and the word "function"
});
$.ajax({
url: "test.html",
context: document.body
}).done(function() {
$( this ).addClass( "done" );
});
// Function accepting an array, no space
foo([ "alpha", "beta" ]);
// Function accepting an object, no space
foo({
a: "alpha",
b: "beta"
});
if ( array.length > 0 ) ...
if ( array.length ) ...
if ( array.length === 0 ) ...
if ( !array.length ) ...
if ( string !== "" ) ...
if ( string ) ...
if ( string === "" ) ...
if ( !string ) ...
if ( foo === true ) ...
if ( foo ) ...
if ( foo === false ) ...
if ( !foo ) ...
if ( foo === null || foo === undefined ) ...
if ( foo == null ) ...
// but not 'false', "" or 0
null == undefined
// TODO: Querido 'yo' del futuro...arregla esto por favor
functionNamesLikeThis;
variableNamesLikeThis;
ConstructorNamesLikeThis;
EnumNamesLikeThis;
methodNamesLikeThis;
SYMBOLIC_CONSTANTS_LIKE_THIS;
""Arguments over style are pointless. There should be a style guide, and you should follow it.
Rebecca Murphey"
Always leave the campground cleaner than you found it.
The Boy Scout Rule
By Anthanh
Descripción del estilo de código del lenguaje JavaScript basado en las propuesta de https://github.com/rwaldron/idiomatic.js/
I ♥ the web, technologies and....beers! Co-founder of https://etereo.io