SlideShare a Scribd company logo
1 of 21
GameCraft Training




                     @Rado_g
 Client-side programming
 Console play >_
 JavaScript 101
 The DOM Tree
 JSON {coolness : “maximum”}
 jQuery (Where things get better)
 Object Oriented Programming – Classes, Interfaces,
  Methods, Scopes
 HTML & CSS (concept level)
 Executed by the Browser (Client side)
   Not(d)e – There’s also Server Side JS
 Serves for
   Doing fancy stuff with the HTML
   Creating richer UI
   AJAX
   Doing Web Applications

 Prototype based, dynamic, scripting language
Netbeans v. >= 6.9
Aptana Studio
JavaScript Development Tools for Eclipse
MyEclipse
Visual Studio (+ Telerik JustCode 4 JavaScript)
VIM
TextMate (ако ядете ябълки)
 Variables – no types. Defined with var
   var a = 5;
   var b = “string”;
   var getRandom = function(arg) { return arg+2; }
 Types are associated with values, not with variables
   typeof
 Arrays – can store different types in one array
   var arr = [1,2,3,4,5];
 Hashes (Maps) – but no Objects as keys
   var keyvalue = {name : “Rado”, age : 21, work :
    “GameCraft”}
 Lets have <script
  type=“text/javascript”>alert(“Hello”)</script> in an
  html page.
 Run the page via a web browser




 Let’s view the code  - include.html
 Also, you can use the src attribute :
  <script type=“text/javascript”
  src=“javascript/include.js”></script>
 JavaScript files end with .js
 You can include as many JavaScript files as you want
 Inclusion order is the order that the <script> tags were
  included

 Let’s view the code  - include2.html + include2.js
 We know how to
   Include JavaScript files in HTML
   Run them in the browser
   View the output in the console
   Define simple variables
 Next  typeof
 JavaScript is Dynamic Language, but there are types too
 Lets have the following code :
  var calc = function(a,b) { return a+b; }
   cacl(5,3)  8;
   calc(“rado”, “rado”)  “radorado”
   calc(true, true)  2
   calc(“rado”, true)  “radotrue”
 What if we want to sum only numbers ?
   Enter, typeof
   typeof(5)  “number”
   typeof(“rado”)  “string”
 Undefined is a special value for undefined variables
 var a; typeof(a); // “undefined”
 typeof(undefined); // “undefined”
 This is a standart check:
  if(typeof(something) !== “undefined”) { … }
 Arrays are defined without initial size
   var arr = []; // empty array
 There are few methods to deal with arrays
   arr.push(2); // now array has one element
   arr[0]; // 2
   arr[1]; // undefined
   arr.length; // 1
 But, if we want to check for arrays :
  typeof(arr) === “object”
 So there is a way :
   arr.constructor === Array (But we will talk later about
     Prototypes)
 Functions are something very important in
  JavaScript
 typeof(func) === “function”
 Functions can :
   Take functions as arguments
   Be anonymous
   Return functions
   Be assigned to variables
   Be Called from variables
 They also create objects and define scope
 Go go examples !
 Scope = visibility of variables
 Closure = function + all variables that are defined in the
    function’s scope
   We can “walk” between different closures
   Closures are created by functions
   A function can see its parent scope
   Window is the object at the top of the hierarchy
   Examples – closures.js
   More info - http://jibbering.com/faq/notes/closures/
 In JavaScript, there are no classes
 JavaScript works with Prototypes
 Objects are created by functions
 The function is the constructor
 Obj.hasOwnProperty() – testing for not
  prototype properties
 Examples – prototype.js, number.js,
  array_prototype.js, string_prototype.js
  namespace.js
{
 description : “XML on diet”,
 meaning : “JavaScript Simple Object Notation”,
 usedFor : [
 { case : “Create JS objects”} , { case : “Model for
 data-transportation”, {case : “Configuration files”}
             ]
 }
 Every big JS library is based on JSON
  configurations
 Examples 
 Always insert ;
 Never use the with() operator – random
  behaviour
 Never use new Array(). Use [] for creating arrays
 Always use === instead of == (== is broken)
 There is no block scope
   Declare all variables at the top of functions
 Avoid global variables as much as possible
 Use new only with InitialCaps variables

More Related Content

What's hot

JavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQueryJavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 

What's hot (20)

JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
 
Introduction to JavaScript Programming
Introduction to JavaScript ProgrammingIntroduction to JavaScript Programming
Introduction to JavaScript Programming
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Java script -23jan2015
Java script -23jan2015Java script -23jan2015
Java script -23jan2015
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
 
All You Need to Know About Type Script
All You Need to Know About Type ScriptAll You Need to Know About Type Script
All You Need to Know About Type Script
 
Anonymous functions in JavaScript
Anonymous functions in JavaScriptAnonymous functions in JavaScript
Anonymous functions in JavaScript
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functions
 
JavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQueryJavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQuery
 
Javascript
JavascriptJavascript
Javascript
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
 

Viewers also liked

A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare
 

Viewers also liked (15)

JavaScript 101 - Class 1
JavaScript 101 - Class 1JavaScript 101 - Class 1
JavaScript 101 - Class 1
 
Game Craft - Company Description
Game Craft - Company DescriptionGame Craft - Company Description
Game Craft - Company Description
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design Patterns
 
Github basics
Github basicsGithub basics
Github basics
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
How to create great slides for presentations
How to create great slides for presentationsHow to create great slides for presentations
How to create great slides for presentations
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
 
10 Tips for WeChat
10 Tips for WeChat10 Tips for WeChat
10 Tips for WeChat
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShare
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 
20 Ideas for your Website Homepage Content
20 Ideas for your Website Homepage Content20 Ideas for your Website Homepage Content
20 Ideas for your Website Homepage Content
 

Similar to JavaScript Basics - GameCraft Training

JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Java Intro
Java IntroJava Intro
Java Intro
backdoor
 
javascript
javascript javascript
javascript
Kaya Ota
 

Similar to JavaScript Basics - GameCraft Training (20)

JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript Misunderstood
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Intro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneIntro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG Cologne
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Jet presentation
Jet presentationJet presentation
Jet presentation
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
 
Java Intro
Java IntroJava Intro
Java Intro
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to Programming
 
AJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdfAJS UNIT-1 2021-converted.pdf
AJS UNIT-1 2021-converted.pdf
 
Javascript
JavascriptJavascript
Javascript
 
javascript
javascript javascript
javascript
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

JavaScript Basics - GameCraft Training

  • 2.  Client-side programming  Console play >_  JavaScript 101  The DOM Tree  JSON {coolness : “maximum”}  jQuery (Where things get better)
  • 3.  Object Oriented Programming – Classes, Interfaces, Methods, Scopes  HTML & CSS (concept level)
  • 4.  Executed by the Browser (Client side)  Not(d)e – There’s also Server Side JS  Serves for  Doing fancy stuff with the HTML  Creating richer UI  AJAX  Doing Web Applications  Prototype based, dynamic, scripting language
  • 5.
  • 6. Netbeans v. >= 6.9 Aptana Studio JavaScript Development Tools for Eclipse MyEclipse Visual Studio (+ Telerik JustCode 4 JavaScript) VIM TextMate (ако ядете ябълки)
  • 7.  Variables – no types. Defined with var  var a = 5;  var b = “string”;  var getRandom = function(arg) { return arg+2; }  Types are associated with values, not with variables  typeof  Arrays – can store different types in one array  var arr = [1,2,3,4,5];  Hashes (Maps) – but no Objects as keys  var keyvalue = {name : “Rado”, age : 21, work : “GameCraft”}
  • 8.  Lets have <script type=“text/javascript”>alert(“Hello”)</script> in an html page.  Run the page via a web browser  Let’s view the code  - include.html
  • 9.  Also, you can use the src attribute : <script type=“text/javascript” src=“javascript/include.js”></script>  JavaScript files end with .js  You can include as many JavaScript files as you want  Inclusion order is the order that the <script> tags were included  Let’s view the code  - include2.html + include2.js
  • 10.  We know how to  Include JavaScript files in HTML  Run them in the browser  View the output in the console  Define simple variables  Next  typeof
  • 11.
  • 12.  JavaScript is Dynamic Language, but there are types too  Lets have the following code : var calc = function(a,b) { return a+b; }  cacl(5,3)  8;  calc(“rado”, “rado”)  “radorado”  calc(true, true)  2  calc(“rado”, true)  “radotrue”  What if we want to sum only numbers ?  Enter, typeof  typeof(5)  “number”  typeof(“rado”)  “string”
  • 13.  Undefined is a special value for undefined variables  var a; typeof(a); // “undefined”  typeof(undefined); // “undefined”  This is a standart check: if(typeof(something) !== “undefined”) { … }
  • 14.  Arrays are defined without initial size  var arr = []; // empty array  There are few methods to deal with arrays  arr.push(2); // now array has one element  arr[0]; // 2  arr[1]; // undefined  arr.length; // 1  But, if we want to check for arrays : typeof(arr) === “object”  So there is a way :  arr.constructor === Array (But we will talk later about Prototypes)
  • 15.  Functions are something very important in JavaScript  typeof(func) === “function”  Functions can :  Take functions as arguments  Be anonymous  Return functions  Be assigned to variables  Be Called from variables  They also create objects and define scope  Go go examples !
  • 16.
  • 17.  Scope = visibility of variables  Closure = function + all variables that are defined in the function’s scope  We can “walk” between different closures  Closures are created by functions  A function can see its parent scope  Window is the object at the top of the hierarchy  Examples – closures.js  More info - http://jibbering.com/faq/notes/closures/
  • 18.
  • 19.  In JavaScript, there are no classes  JavaScript works with Prototypes  Objects are created by functions  The function is the constructor  Obj.hasOwnProperty() – testing for not prototype properties  Examples – prototype.js, number.js, array_prototype.js, string_prototype.js namespace.js
  • 20. { description : “XML on diet”, meaning : “JavaScript Simple Object Notation”, usedFor : [ { case : “Create JS objects”} , { case : “Model for data-transportation”, {case : “Configuration files”} ] }  Every big JS library is based on JSON configurations  Examples 
  • 21.  Always insert ;  Never use the with() operator – random behaviour  Never use new Array(). Use [] for creating arrays  Always use === instead of == (== is broken)  There is no block scope  Declare all variables at the top of functions  Avoid global variables as much as possible  Use new only with InitialCaps variables