0
Basics
Basics History Variable Type Statement Review Battle against Coding Horror                                 Basics
History JavaScript – What a Dummy name nothing to do with                        Java ! except the name & year of birthda...
Variable Type 1/2 Boolean, Number, String, Date, Array, Object, Function, null,undefined                        var varia...
Variable Type 2/2 Use JSON to improve consistencevar comment = {      title: ‘my title’,      date: new Date(),      body...
Statement Review Use coding style    functionNamesLikeThis;    variableNamesLikeThis;    ConstructorNamesLikeThis;    Enu...
Battle against Coding Horror Split big JS file into multiples files name your file regarding the namespace/namespace/nam...
Let’s go Decide to look code around you and tryto apply 3 recommandations a week Have Fun !                To be continu...
Upcoming SlideShare
Loading in...5
×

JS - Basics

190

Published on

Starting point to Jump into JavaScript

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
190
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "JS - Basics"

  1. 1. Basics
  2. 2. Basics History Variable Type Statement Review Battle against Coding Horror Basics
  3. 3. History JavaScript – What a Dummy name nothing to do with Java ! except the name & year of birthdate 1995 Prefer the reference to EMACScript 5 last revision in december 2009 Suffering as Popup langage and unconsistence Comparing The « Grail » POO (Java / C++) New Dynamic from AJAX ( Web 2.0) has become in 2007 Recently NodeJS 2010 (JS on Server-Side) Basics Cloud (rich Client-Side apps)
  4. 4. Variable Type 1/2 Boolean, Number, String, Date, Array, Object, Function, null,undefined var variable; undefined ?Mutiple variable declaration at top of inner functionvar variable1, variable2, variable2; Use simple quote as double quote to improveconsistent and readability Basics
  5. 5. Variable Type 2/2 Use JSON to improve consistencevar comment = { title: ‘my title’, date: new Date(), body: ‘my comment’}; Declare Array with [] and Object with {}var comments = [];comments.push(comment);comments.render = function() { /* comments collection rendering */} BasicsPrefer Declare function with = function() { }Use delete keyword to delete variable
  6. 6. Statement Review Use coding style functionNamesLikeThis; variableNamesLikeThis; ConstructorNamesLikeThis; EnumNamesLikeThis; methodNamesLikeThis; SYMBOLIC_CONSTANTS_LIKE_THIS; extract from Google Closure Library Style Guide Always put brachet on statement and space on test if ( test ) { /* something to do */ } Forget eval function you are going wrong ! Max 3 level of indentation otherwise it means you are going wrong extract from Linux Kernel Coding Style Strip whitespace and always use 4 spaces as tab spacing Use triple equality test === to avoid implicit type coercion Basics
  7. 7. Battle against Coding Horror Split big JS file into multiples files name your file regarding the namespace/namespace/namespace.Class.js Use Namespace Pattern to group your Classes & ObjectInstancesvar namespace = namespace || {};namespace.instance = new namespace.Class; Max target size of lines should be lower than 250 Basics
  8. 8. Let’s go Decide to look code around you and tryto apply 3 recommandations a week Have Fun ! To be continue… Fundamental JS Basics
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×