SlideShare a Scribd company logo
JavaScript for Java Developers
Trainer: Igor Khotin
Contacts: khotin@gmx.com
1990 – World Wide Web1990 – World Wide Web
1993 – NCSA Mosaic1993 – NCSA Mosaic
1994 - Netscape Navigator1994 - Netscape Navigator
1995 – Sun Java1995 – Sun Java
JavaScript Origins – LiveScriptJavaScript Origins – LiveScript
Interpreted scripting language
Simple enough for beginners
Dialect of Scheme
Self-inspired prototype model
HyperCard event model
Java syntax
Brendan Eich
JavaScript Origins – LiveScriptJavaScript Origins – LiveScript
Interpreted scripting language
Simple enough for beginners
Dialect of Scheme
Self-inspired prototype model
HyperCard event model
Java syntax
Brendan Eich
Implemented in 10 days
Netscape – Sun dealNetscape – Sun deal
&
Java Applets for appsJava Applets for apps
&
Simple script for web designersSimple script for web designers
&
Script?
1995 - JavaScript Released1995 - JavaScript Released
&
1995 - JavaScript Released1995 - JavaScript Released
&
Internet ExplorerInternet Explorer
2005 - AJAX2005 - AJAX
Today – The Most Popular Client PlatformToday – The Most Popular Client Platform
In Fact – The Only Option on Web ClientIn Fact – The Only Option on Web Client
New fast engines – Google V8New fast engines – Google V8
JavaScript “strict mode”JavaScript “strict mode”
Mozilla RhinoMozilla Rhino
JavaScript engine shipped with JRE (version 6 and higher)
NashornNashorn
Much faster JavaScript engine in JRE 8
Server Apps with Node.jsServer Apps with Node.js
JavaScript server platform
based on Google V8 engine
Desktop Apps with Node-WebkitDesktop Apps with Node-Webkit
How Developers Learn JavaScriptHow Developers Learn JavaScript
Hmm... JavaScript...
Looks familiar...
Let the coding begin!!!
It will make you think...It will make you think...
After a little while...After a little while...
I hate JavaScript!!!
What I really mean...What I really mean...
I don't understand the language
It has stupid features
The DOM model is EVIL
Java & JavaScriptJava & JavaScript
JavaScript != Java
Java & JavaScript – What is SimilarJava & JavaScript – What is Similar
C-like syntax
Sandboxed
Java keywords are reserved in js
JS follows Java naming
conventions
Java & JavaScript – What is SimilarJava & JavaScript – What is Similar
C-like syntax
Sandboxed
Java keywords are reserved in js
JS follows Java naming
conventions
Make harder to see the
difference!
JavaScriptJavaScript
Dynamic Typing
Prototype-based
Dynamic Objects
First Class Functions
Closures
Function Scope
Global Variables
Know and Avoid Bad FeaturesKnow and Avoid Bad Features
Don't Use DOM DirectlyDon't Use DOM Directly
JQuery
Prototype
...
Global ScopeGlobal Scope
Window object = context
Avoid global variables
Automatic SemicolonsAutomatic Semicolons
return {
status: true
}
{ status: true }
return
{
status: true
}
undefined
Automatic SemicolonsAutomatic Semicolons
return {
status: true
}
{ status: true }
return;
{
status: true
}
undefined
What is the difference?What is the difference?
console.log('multiline string 
Literal');
console.log('multiline string 
Literal');
You can't see itYou can't see it
console.log('multiline string 
Literal');
console.log('multiline string _
Literal'); ^
====
'' == '0' // false
0 == '' // true
0 == '0' // true
false == 'false' // false
false == '0' // true
false == undefined // false
false == null // false
null == undefined // true
' trn ' == 0 // true
Use === and !== insteadUse === and !== instead
'' === '0' // false
0 === '' // false
0 === '0' // false
false === 'false' // false
false === '0' // false
false === undefined // false
false === null // false
null === undefined // false
' trn ' === 0 // false
undefined valuesundefined values
value == null
Use === and !== insteadUse === and !== instead
value == null
value === undefined
Only floating point numbersOnly floating point numbers
0.3 - 0.1 !== 0.2
typeoftypeof
typeof 0.2 // 'number'
typeof {} // 'object'
typeof [] // 'object'
typeof null // 'object'
typeof NaN // 'number'
Function ScopeFunction Scope
function checkScope() {
{
var foo = 42;
}
// foo is still visible!
}
Use the Power of Good FeaturesUse the Power of Good Features
Weak TypingWeak Typing
Variables are containers that could store everything
Objects as Hash TablesObjects as Hash Tables
function Person(name) {
this._name = name;
this.getName = function() {
return this._name;
};
}
var person = new Person("John");
person.age = 27;
person["city"] = "London"
Objects Literals, eval() and JSONObjects Literals, eval() and JSON
var myCar = {
color: "yellow",
wheels: 4,
engine: {
cylinders: 4,
size: 2.0
}
};
First Value FunctionsFirst Value Functions
var plus = function(x,y){ return x + y };
var minus = function(x,y){ return x - y };
var operations = {
'+': plus,
'-': minus
};
var calculate = function(x, y, operation){
return operations[operation](x, y);
}
calculate(38, 4, '+');
calculate(47, 3, '-');
ClosuresClosures
function add(value1) {
return function doAdd(value2) {
return value1 + value2;
};
}
var increment = add(1);
var foo = increment(2);
// foo equals 3
PrototypesPrototypes
var Point = function(x) {
this.x = x;
return this;
};
Point.prototype = {
x: 0,
draw: function() { … }
};
p1 = new Point(10);
p2 = new Point(15);
this as function contextthis as function context
function bar() {
alert(this);
}
bar(); // global
var foo = {
baz: function() {
alert(this);
}
}
foo.baz(); // foo
Resources
JavaScript – The Good Parts
Douglas Crockford
JavaScript Patterns
Stoyan Stefanov
Questions

More Related Content

PDF
JavaScript For CSharp Developer
PPTX
Introduction to JavaScript Programming
KEY
The JavaScript Programming Primer
ODP
Javascript
PPTX
All You Need to Know About Type Script
PDF
Basics of JavaScript
PPTX
PHP Basics
PPT
Web development basics (Part-4)
JavaScript For CSharp Developer
Introduction to JavaScript Programming
The JavaScript Programming Primer
Javascript
All You Need to Know About Type Script
Basics of JavaScript
PHP Basics
Web development basics (Part-4)

What's hot (20)

PPTX
JS - Basics
PPTX
Object Oriented Programming In JavaScript
PPT
JavaScript Basics
PPTX
JavaScript Basics - GameCraft Training
PPTX
OOP->A Bird's-eye view
PDF
Working with Cocoa and Objective-C
ODP
JavaScript Object Oriented Programming Cheat Sheet
PPTX
Java scriptforjavadev part1
PDF
Object Oriented Programming in JavaScript
PDF
JavaScript Basics and Best Practices - CC FE & UX
PPTX
Type script - advanced usage and practices
PPTX
Javascript basics for automation testing
PPT
Java script unleashed
PPTX
Ruby Programming Language - Introduction
PPT
Developing Android applications with Ceylon
PDF
JavaScript - From Birth To Closure
PDF
Fundamental JavaScript [UTC, March 2014]
PDF
JavaScript OOPs
PPTX
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
JS - Basics
Object Oriented Programming In JavaScript
JavaScript Basics
JavaScript Basics - GameCraft Training
OOP->A Bird's-eye view
Working with Cocoa and Objective-C
JavaScript Object Oriented Programming Cheat Sheet
Java scriptforjavadev part1
Object Oriented Programming in JavaScript
JavaScript Basics and Best Practices - CC FE & UX
Type script - advanced usage and practices
Javascript basics for automation testing
Java script unleashed
Ruby Programming Language - Introduction
Developing Android applications with Ceylon
JavaScript - From Birth To Closure
Fundamental JavaScript [UTC, March 2014]
JavaScript OOPs
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Ad

Viewers also liked (12)

PDF
Keynote on JavaDay Omsk 2014 about new features in Java 8
PPTX
Java Core. Lecture# 1. Intro
PPTX
Клиентская Java вне браузера. Делаем нативные клиенты на Java
PPTX
Java Ahead-Of-Time compilation
PPTX
Expert Java Day: Java concurrency
PDF
Java худеет. Спроси меня как.
PDF
Java худеет. Спроси меня как. Уменьшение размера дистрибутива Java приложения...
PDF
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 дней
PPTX
Классы и объекты в Java
PDF
Date & Time in Java SE 8
PPT
Секреты сборки мусора в Java
ODP
Java: вчера, сегодня, завтра
Keynote on JavaDay Omsk 2014 about new features in Java 8
Java Core. Lecture# 1. Intro
Клиентская Java вне браузера. Делаем нативные клиенты на Java
Java Ahead-Of-Time compilation
Expert Java Day: Java concurrency
Java худеет. Спроси меня как.
Java худеет. Спроси меня как. Уменьшение размера дистрибутива Java приложения...
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 дней
Классы и объекты в Java
Date & Time in Java SE 8
Секреты сборки мусора в Java
Java: вчера, сегодня, завтра
Ad

Similar to WDB005.1 - JavaScript for Java Developers (Lecture 1) (20)

PDF
slides-students-C03.pdf
PDF
JavaScript Programming
PDF
Javascriptbootcamp
PDF
Isomorphic App Development with Ruby and Volt - Rubyconf2014
PDF
Lagergren jvmls-2013-final
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
PDF
Javascript status 2016
PPT
Douglas Crockford Presentation Goodparts
PPT
Goodparts
PDF
JavaScript
KEY
Ruby on Rails survival guide of an aged Java developer
PDF
JavaScript Interview Questions PDF By ScholarHat
KEY
A tour on ruby and friends
PPT
Introduction to Javascript
PPT
introduction to javascript concepts .ppt
PPTX
Java script.pptx v
PPTX
JavaScript (without DOM)
PDF
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
PPTX
Java script basics
slides-students-C03.pdf
JavaScript Programming
Javascriptbootcamp
Isomorphic App Development with Ruby and Volt - Rubyconf2014
Lagergren jvmls-2013-final
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
Javascript status 2016
Douglas Crockford Presentation Goodparts
Goodparts
JavaScript
Ruby on Rails survival guide of an aged Java developer
JavaScript Interview Questions PDF By ScholarHat
A tour on ruby and friends
Introduction to Javascript
introduction to javascript concepts .ppt
Java script.pptx v
JavaScript (without DOM)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Java script basics

More from Igor Khotin (9)

ODP
The craft of meta programming on JVM
ODP
Spring cloud for microservices architecture
ODP
Gradle - time for another build
PDF
Gradle - time for a new build
PDF
Business value in game development
PDF
Cassandra Prophecy
ODP
Gradle - next generation of build tools
ODP
XML Magic
ODP
Igor Khotin - Domain Specific Languages
The craft of meta programming on JVM
Spring cloud for microservices architecture
Gradle - time for another build
Gradle - time for a new build
Business value in game development
Cassandra Prophecy
Gradle - next generation of build tools
XML Magic
Igor Khotin - Domain Specific Languages

Recently uploaded (20)

PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Transform Your Business with a Software ERP System
PPTX
L1 - Introduction to python Backend.pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
System and Network Administration Chapter 2
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
top salesforce developer skills in 2025.pdf
PPTX
Introduction to Artificial Intelligence
PPTX
ai tools demonstartion for schools and inter college
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
AI in Product Development-omnex systems
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Digital Strategies for Manufacturing Companies
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Design an Analysis of Algorithms II-SECS-1021-03
ManageIQ - Sprint 268 Review - Slide Deck
Transform Your Business with a Software ERP System
L1 - Introduction to python Backend.pptx
How to Migrate SBCGlobal Email to Yahoo Easily
System and Network Administration Chapter 2
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
top salesforce developer skills in 2025.pdf
Introduction to Artificial Intelligence
ai tools demonstartion for schools and inter college
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
AI in Product Development-omnex systems
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers
Online Work Permit System for Fast Permit Processing
Operating system designcfffgfgggggggvggggggggg
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Understanding Forklifts - TECH EHS Solution
Digital Strategies for Manufacturing Companies
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises

WDB005.1 - JavaScript for Java Developers (Lecture 1)