SlideShare a Scribd company logo
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 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)
Variable Type 1/2

Boolean, Number, String, Date, Array, Object, Function, null, undefi
ned
                        var variable;
 undefined ?
Mutiple variable declaration at top of inner function
var variable1,
     variable2,
     variable2;


 Use simple quote as double quote to improve                Basics
consistent and readability
Variable Type 2/2
 Use JSON to improve consistence
var 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
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
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 & Object
Instances

var namespace = namespace || {};
namespace.instance = new namespace.Class;

 Max target size of lines should be lower than 250
                                                         Basics
Let’s go

 Decide to look code around you and try
to apply 3 recommandations a week
 Have Fun !


                To be continue… Fundamental JS

                                          Basics

More Related Content

PPTX
JavaScript Basics
PPTX
PHP Basics
PPT
Web development basics (Part-4)
PPTX
An Introduction to JavaScript
PPTX
Javascript functions
PPTX
Java script
PPTX
Lecture 5 javascript
PPTX
Introduction to JavaScript
JavaScript Basics
PHP Basics
Web development basics (Part-4)
An Introduction to JavaScript
Javascript functions
Java script
Lecture 5 javascript
Introduction to JavaScript

What's hot (20)

PPTX
Placement and variable 03 (js)
PPTX
Introduction to JavaScript Programming
PPTX
Introduction to JavaScript Programming
PPTX
Advanced Javascript
PPTX
Introduction to JavaScript Basics.
PDF
3. Java Script
PDF
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
PPTX
JavaScript operators
PPT
introduction to javascript
PPTX
Typescript
PPT
Introduction to JavaScript
PDF
8 introduction to_java_script
PPT
Javascript Basics
ODP
Getting started with typescript and angular 2
PPTX
javascript
PPTX
JavaScript Fundamentals & JQuery
PPT
A Deeper look into Javascript Basics
PPTX
002. Introducere in type script
DOC
Typescript Basics
Placement and variable 03 (js)
Introduction to JavaScript Programming
Introduction to JavaScript Programming
Advanced Javascript
Introduction to JavaScript Basics.
3. Java Script
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript operators
introduction to javascript
Typescript
Introduction to JavaScript
8 introduction to_java_script
Javascript Basics
Getting started with typescript and angular 2
javascript
JavaScript Fundamentals & JQuery
A Deeper look into Javascript Basics
002. Introducere in type script
Typescript Basics
Ad

Viewers also liked (20)

PPTX
Community capacity development_project1
PPTX
Polonnaruwa drinking water_project
PDF
Data Sheet Shinta Pdf
PPTX
I pods
PPTX
4 Gsm Net Architecture Manish Copy Copy
PPT
CR SF OLPC Summit par Jonathan
PPTX
Mobile medical clinic_project2_
PPTX
JS - Basics
PPTX
Assemblée Générale OLPC 2010 - Bilan moral et perspectives
PPT
Cardiac Medications Review 2011
PDF
Jeu vidéo et apprentissage : quelles théorisations pour quelles pratiques ?
PDF
Proscan media - Premier Thermal and sheet label and thermal ribbons solutions...
PPTX
Survillence Project
PPT
Idiom Project
PPT
Mad(Mobile Advertising ) Card
PPSX
Titanic
PPT
Cardiac medications nursing review 2011
PDF
236135365 heat-treatment-manual
PPS
Vive Le Camping Car
Community capacity development_project1
Polonnaruwa drinking water_project
Data Sheet Shinta Pdf
I pods
4 Gsm Net Architecture Manish Copy Copy
CR SF OLPC Summit par Jonathan
Mobile medical clinic_project2_
JS - Basics
Assemblée Générale OLPC 2010 - Bilan moral et perspectives
Cardiac Medications Review 2011
Jeu vidéo et apprentissage : quelles théorisations pour quelles pratiques ?
Proscan media - Premier Thermal and sheet label and thermal ribbons solutions...
Survillence Project
Idiom Project
Mad(Mobile Advertising ) Card
Titanic
Cardiac medications nursing review 2011
236135365 heat-treatment-manual
Vive Le Camping Car
Ad

Similar to JS Basics (20)

PDF
Training javascript 2012 hcmut
PPT
Javascript sivasoft
PDF
javascript teach
PDF
JSBootcamp_White
PPTX
Java script
PPTX
Java Script basics and DOM
PDF
Basics of JavaScript
PPT
Ajax and JavaScript Bootcamp
PPTX
Building maintainable javascript applications
PDF
Choosing Javascript Libraries to Adopt for Development
PPTX
Javascript fundamentals and not
PDF
A Re-Introduction to JavaScript
PDF
Lecture7
PPT
Week 7
PPTX
Introduction to Client-Side Javascript
PPT
JavaScript - An Introduction
PPTX
Javascript Best Practices and Intro to Titanium
PPT
JavaScript Misunderstood
PPT
Javascript
Training javascript 2012 hcmut
Javascript sivasoft
javascript teach
JSBootcamp_White
Java script
Java Script basics and DOM
Basics of JavaScript
Ajax and JavaScript Bootcamp
Building maintainable javascript applications
Choosing Javascript Libraries to Adopt for Development
Javascript fundamentals and not
A Re-Introduction to JavaScript
Lecture7
Week 7
Introduction to Client-Side Javascript
JavaScript - An Introduction
Javascript Best Practices and Intro to Titanium
JavaScript Misunderstood
Javascript

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PDF
KodekX | Application Modernization Development
PPTX
Big Data Technologies - Introduction.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
sap open course for s4hana steps from ECC to s4
Encapsulation_ Review paper, used for researhc scholars
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology
MIND Revenue Release Quarter 2 2025 Press Release
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Understanding_Digital_Forensics_Presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
KodekX | Application Modernization Development
Big Data Technologies - Introduction.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25 Week I

JS Basics

  • 2. Basics  History  Variable Type  Statement Review  Battle against Coding Horror Basics
  • 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. Variable Type 1/2  Boolean, Number, String, Date, Array, Object, Function, null, undefi ned var variable;  undefined ? Mutiple variable declaration at top of inner function var variable1, variable2, variable2;  Use simple quote as double quote to improve Basics consistent and readability
  • 5. Variable Type 2/2  Use JSON to improve consistence var 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. 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. 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 & Object Instances var namespace = namespace || {}; namespace.instance = new namespace.Class;  Max target size of lines should be lower than 250 Basics
  • 8. Let’s go  Decide to look code around you and try to apply 3 recommandations a week  Have Fun ! To be continue… Fundamental JS Basics