SlideShare a Scribd company logo
1 of 19
Download to read offline
Introduction to JS
Aleksander Fabijan
Agenda
1. Introduction to AA
2. Background of JS
3. The Basics
a. Statements
b. Variables
c. Data Types (Strings, Objects, Arrays)
d. Functions
About Aleksander
1.
History of JS
The background behind the language of the web.
Brief History of JS
▷ 1995: At Netscape, Brendan Eich created "JavaScript".
▷ 1996: Microsoft releases "JScript", a port for IE3.
▷ 1997: JavaScript was standardized in the "ECMAScript" spec.
▷ 2005: "AJAX" was coined and the web 2.0 age begins.
▷ 2006: jQuery 1.0 was released.
▷ 2010: Node.JS was released.
▷ 2015: ECMAScript 6 was released.
▷ 2016: Microsoft releases HoloJS.
▷ 2017: You started this class.
2.
The Basics
Statements, variables, functions etc.
Tools
Text editor (Atom, Visual Studio Code, etc.)
Chrome Developer Tools
Statements
Each instruction in JS is a "statement", like:
console.log('Hello World!');
Try it out: https://jsbin.com/
Variables
Declare, then
initialize in 2
statements:
var x;
x = 5;
console.log(x);
Or declare and
initialize in one
statement:
var y = 2;
console.log(y);
Re-assign the value
later:
y = 4;
console.log(y);
Primitive Data Types
Strings
A string holds an ordered list of character:
var alphabet = "abcdefghijklmnopqrstuvwxyz";
The length property reports the size of the string:
console.log(alphabet.length); // 26
Each character has an index. The first character is always at index 0.
The last character is always at index length-1:
console.log(alphabet[0]); // 'a'
console.log(alphabet[1]); // 'b'
console.log(alphabet[2]); // 'c'
console.log(alphabet[alphabet.length]); // undefined
console.log(alphabet[alphabet.length-1]); // 'z'
console.log(alphabet[alphabet.length-2]); // 'y'
Objects
var obj = {
name: "Carrot",
"for": "Max",
details: {
color: "orange",
size: 12
}
}
Array
var a = new Array();
a[0] = "dog";
a[1] = "cat";
a.push("parrot");
a.length; // 3
OR
var a = ["dog", "cat", "parrot"];
a.length; // 3
Fun fact
array.length isn't necessarily the number of items in the
array.
Example:
var a = ["dog", "cat", "parrot"];
a[100] = "koala";
a.length; // 101 ---OMG!!!
Fun fact 2
var x = "Volvo" + “16”;
var x = "Volvo" + 16;
var x = "Volvo" + 1+6;
What Happens?
Functions
Functions are re-usable collections of statements.
First declare the function:
function returnMyName() {
console.log('Hi Aleksander!');
}
Then call it (as many times as you want):
returnMyName();
Interactive:
https://repl.it/classroom/invite/CSUTVb0
http://bit.ly/2iKJyBP
3.
Resources
Useful resources
https://jsbin.com (write and execute JS online)
https://jsfiddle.net/ (JS, CSS and HTML playground)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_r
e-introduction_to_JavaScript (a re-intro to JS)
Thanks!
You can find me at:
aleksander.fabijan@mah.se

More Related Content

Viewers also liked

Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to JavascriptAnjan Banda
 
NodeJs Intro - JavaScript Zagreb Meetup #1
NodeJs Intro - JavaScript Zagreb Meetup #1NodeJs Intro - JavaScript Zagreb Meetup #1
NodeJs Intro - JavaScript Zagreb Meetup #1Tomislav Capan
 
VT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSSVT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSSAnton Tibblin
 
JavaScript Intro
JavaScript IntroJavaScript Intro
JavaScript IntroEric Brown
 
History of JavaScript
History of JavaScriptHistory of JavaScript
History of JavaScriptRajat Saxena
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to JavascriptKevin Ball
 
Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQueryShawn Calvert
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptDan Phiffer
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 

Viewers also liked (16)

Introduction to js (cnt.)
Introduction to js (cnt.)Introduction to js (cnt.)
Introduction to js (cnt.)
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
NodeJs Intro - JavaScript Zagreb Meetup #1
NodeJs Intro - JavaScript Zagreb Meetup #1NodeJs Intro - JavaScript Zagreb Meetup #1
NodeJs Intro - JavaScript Zagreb Meetup #1
 
Intro to javascript (4 week)
Intro to javascript (4 week)Intro to javascript (4 week)
Intro to javascript (4 week)
 
VT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSSVT17 - DA355A - Introduktion till CSS
VT17 - DA355A - Introduktion till CSS
 
JavaScript Intro
JavaScript IntroJavaScript Intro
JavaScript Intro
 
History of JavaScript
History of JavaScriptHistory of JavaScript
History of JavaScript
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
JavaScript - Intro
JavaScript - IntroJavaScript - Intro
JavaScript - Intro
 
Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQuery
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
jQuery and Ajax
jQuery and AjaxjQuery and Ajax
jQuery and Ajax
 
Bootstrap 3 Basic - Bangkok WordPress Meetup
Bootstrap 3 Basic - Bangkok WordPress MeetupBootstrap 3 Basic - Bangkok WordPress Meetup
Bootstrap 3 Basic - Bangkok WordPress Meetup
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 

Similar to Javascript intro for MAH

Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesJamund Ferguson
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Troy Miles
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
Runtime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya RathoreRuntime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya RathoreEsha Yadav
 
Os Vanrossum
Os VanrossumOs Vanrossum
Os Vanrossumoscon2007
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to ProgrammingCindy Royal
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript BootcampAndreCharland
 
Java script
 Java script Java script
Java scriptbosybosy
 
Java Intro
Java IntroJava Intro
Java Introbackdoor
 
Ts archiving
Ts   archivingTs   archiving
Ts archivingConfiz
 

Similar to Javascript intro for MAH (20)

Don't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax TreesDon't Be Afraid of Abstract Syntax Trees
Don't Be Afraid of Abstract Syntax Trees
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Javascript status 2016
Javascript status 2016Javascript status 2016
Javascript status 2016
 
Java script
Java scriptJava script
Java script
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Modern JS with ES6
Modern JS with ES6Modern JS with ES6
Modern JS with ES6
 
Runtime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya RathoreRuntime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya Rathore
 
Os Vanrossum
Os VanrossumOs Vanrossum
Os Vanrossum
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to Programming
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
 
jsbasics-slide
jsbasics-slidejsbasics-slide
jsbasics-slide
 
Java script
 Java script Java script
Java script
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Java Intro
Java IntroJava Intro
Java Intro
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 

More from Aleksander Fabijan

Python oop - class 2 (inheritance)
Python   oop - class 2 (inheritance)Python   oop - class 2 (inheritance)
Python oop - class 2 (inheritance)Aleksander Fabijan
 
Introduction to OOP in python inheritance
Introduction to OOP in python   inheritanceIntroduction to OOP in python   inheritance
Introduction to OOP in python inheritanceAleksander Fabijan
 
The evolution of continuous experimentation in software product development: ...
The evolution of continuous experimentation in software product development: ...The evolution of continuous experimentation in software product development: ...
The evolution of continuous experimentation in software product development: ...Aleksander Fabijan
 
Introduction to data visualisation with D3
Introduction to data visualisation with D3Introduction to data visualisation with D3
Introduction to data visualisation with D3Aleksander Fabijan
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodologyAleksander Fabijan
 

More from Aleksander Fabijan (9)

Retrospective 1
Retrospective 1Retrospective 1
Retrospective 1
 
Python oop third class
Python oop   third classPython oop   third class
Python oop third class
 
Python oop - class 2 (inheritance)
Python   oop - class 2 (inheritance)Python   oop - class 2 (inheritance)
Python oop - class 2 (inheritance)
 
Python oop class 1
Python oop   class 1Python oop   class 1
Python oop class 1
 
Introduction to OOP in python inheritance
Introduction to OOP in python   inheritanceIntroduction to OOP in python   inheritance
Introduction to OOP in python inheritance
 
Introduction to OOP in Python
Introduction to OOP in PythonIntroduction to OOP in Python
Introduction to OOP in Python
 
The evolution of continuous experimentation in software product development: ...
The evolution of continuous experimentation in software product development: ...The evolution of continuous experimentation in software product development: ...
The evolution of continuous experimentation in software product development: ...
 
Introduction to data visualisation with D3
Introduction to data visualisation with D3Introduction to data visualisation with D3
Introduction to data visualisation with D3
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodology
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Javascript intro for MAH

  • 2. Agenda 1. Introduction to AA 2. Background of JS 3. The Basics a. Statements b. Variables c. Data Types (Strings, Objects, Arrays) d. Functions
  • 4. 1. History of JS The background behind the language of the web.
  • 5. Brief History of JS ▷ 1995: At Netscape, Brendan Eich created "JavaScript". ▷ 1996: Microsoft releases "JScript", a port for IE3. ▷ 1997: JavaScript was standardized in the "ECMAScript" spec. ▷ 2005: "AJAX" was coined and the web 2.0 age begins. ▷ 2006: jQuery 1.0 was released. ▷ 2010: Node.JS was released. ▷ 2015: ECMAScript 6 was released. ▷ 2016: Microsoft releases HoloJS. ▷ 2017: You started this class.
  • 7. Tools Text editor (Atom, Visual Studio Code, etc.) Chrome Developer Tools
  • 8. Statements Each instruction in JS is a "statement", like: console.log('Hello World!'); Try it out: https://jsbin.com/
  • 9. Variables Declare, then initialize in 2 statements: var x; x = 5; console.log(x); Or declare and initialize in one statement: var y = 2; console.log(y); Re-assign the value later: y = 4; console.log(y);
  • 11. Strings A string holds an ordered list of character: var alphabet = "abcdefghijklmnopqrstuvwxyz"; The length property reports the size of the string: console.log(alphabet.length); // 26 Each character has an index. The first character is always at index 0. The last character is always at index length-1: console.log(alphabet[0]); // 'a' console.log(alphabet[1]); // 'b' console.log(alphabet[2]); // 'c' console.log(alphabet[alphabet.length]); // undefined console.log(alphabet[alphabet.length-1]); // 'z' console.log(alphabet[alphabet.length-2]); // 'y'
  • 12. Objects var obj = { name: "Carrot", "for": "Max", details: { color: "orange", size: 12 } }
  • 13. Array var a = new Array(); a[0] = "dog"; a[1] = "cat"; a.push("parrot"); a.length; // 3 OR var a = ["dog", "cat", "parrot"]; a.length; // 3
  • 14. Fun fact array.length isn't necessarily the number of items in the array. Example: var a = ["dog", "cat", "parrot"]; a[100] = "koala"; a.length; // 101 ---OMG!!!
  • 15. Fun fact 2 var x = "Volvo" + “16”; var x = "Volvo" + 16; var x = "Volvo" + 1+6; What Happens?
  • 16. Functions Functions are re-usable collections of statements. First declare the function: function returnMyName() { console.log('Hi Aleksander!'); } Then call it (as many times as you want): returnMyName(); Interactive: https://repl.it/classroom/invite/CSUTVb0 http://bit.ly/2iKJyBP
  • 18. Useful resources https://jsbin.com (write and execute JS online) https://jsfiddle.net/ (JS, CSS and HTML playground) https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_r e-introduction_to_JavaScript (a re-intro to JS)
  • 19. Thanks! You can find me at: aleksander.fabijan@mah.se