SlideShare a Scribd company logo
JavaScript
2016/12/11, HsinChu, NCTU
Takeshi
1
Outline
• Introduction
• Basic syntax
• Functions
• Useful Data structures/types
2
Introduction
• High-level programming language
• Supported by all modern browser/OS
• Frontend (Browser, UI control, …)
• Backend (Server, Application)
• Interpreted programming language
• Weakly typed
3
JavaScript is NOT Java
4
Basic syntax (1/2)
• define variable(s)
var a = 1;
• Do basic calculation
sum = a + b;
• Loops
for (a=0; a<10; a++) {
// do something cool…
}
5
Basic syntax (2/2)
• Print something on console
console.log(“hello world”);
• Everything can stored in a variable
var a = 3.1415926, s = “this is a string”;
var sum = function (a, b) {
return a + b;
}
• If/Else
if (a === 1) {
// do something…..
}
6
Quick Demo
9 x 9 Table
Functions (1/3)
• Builtin functions
• Console functions
• eval
• Functions for some specific data structure
• User defined functions
Functions (2/3)
• Define a function:
var foo = function (parameters) {
// function content
}
• Call a function:
foo();
Functions (3/3)
• Function can be anonymous (and parameter):
executeThisFunctionWithLog(function() {
// do something
});
Quick Demo
simple functions
Callback function (1/2)
• For asynchronous design.
• Call function(s) after something done.
• Won’t block anything
Callback function (2/2)
• For example, we don’t want to block anything while we
are loading some data from API.
var cb = function(result) {
console.log(result);
}
fetchUrl(“https://api.cdnjs.com/libraries“, cb);
Quick Demo
Do something after 1 second
Callback hell (1/2)
• If we want to call multiple async functions……
fetchApi(“first.api.com”, function(result) {
// do something first and fetch another API
fetchApi(“second.api.com”, function(result) {
// call another async function
});
});
Callback hell (2/2)
• To resolve callback hell we can use:
• Async library
• Promise
• async/await syntax (ES7)
Useful data types
• Some useful data types:
// list (array)
var l = [1, 2, “3”, “abc”, {“the”: “map”}];
// map
var m = {“key”: value};
// boolean
var b = true;
Thanks
Questions?

More Related Content

PPTX
2016 NCTU P4 Workshop
PDF
20170925 onos and p4
PDF
Programming Protocol-Independent Packet Processors
PDF
Networking and Go: An Epic Journey
PDF
[Webinar Slides] Programming the Network Dataplane in P4
PDF
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...
PDF
Protocol Independence
PDF
Network Measurement with P4 and C on Netronome Agilio
2016 NCTU P4 Workshop
20170925 onos and p4
Programming Protocol-Independent Packet Processors
Networking and Go: An Epic Journey
[Webinar Slides] Programming the Network Dataplane in P4
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...
Protocol Independence
Network Measurement with P4 and C on Netronome Agilio

What's hot (20)

PDF
LAS16-TR02: Upstreaming 101
PDF
Stacks and Layers: Integrating P4, C, OVS and OpenStack
PDF
Socket Programming using Java
PDF
Programmable data plane at terabit speeds
PDF
Transparent eBPF Offload: Playing Nice with the Linux Kernel
PDF
P4 for Custom Identification, Flow Tagging, Monitoring and Control
PPTX
Compiling P4 to XDP, IOVISOR Summit 2017
PDF
LAS16-504: Secure Storage updates in OP-TEE
PPTX
Kernel Proc Connector and Containers
PDF
Getting Started with Performance Co-Pilot
PDF
Programming the Network Data Plane
PDF
FBTFTP: an opensource framework to build dynamic tftp servers
PDF
Performance optimization 101 - Erlang Factory SF 2014
PDF
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
PDF
Flink Forward Berlin 2017: Andreas Kunft - Efficiently executing R Dataframes...
PDF
OpenZFS at LinuxCon
PDF
HBase Coprocessors @ HUG NYC
PPTX
Nov. 4, 2011 o reilly webcast-hbase- lars george
PDF
Flink Forward Berlin 2017: Patrick Lucas - Flink in Containerland
PPTX
0.5mln packets per second with Erlang
LAS16-TR02: Upstreaming 101
Stacks and Layers: Integrating P4, C, OVS and OpenStack
Socket Programming using Java
Programmable data plane at terabit speeds
Transparent eBPF Offload: Playing Nice with the Linux Kernel
P4 for Custom Identification, Flow Tagging, Monitoring and Control
Compiling P4 to XDP, IOVISOR Summit 2017
LAS16-504: Secure Storage updates in OP-TEE
Kernel Proc Connector and Containers
Getting Started with Performance Co-Pilot
Programming the Network Data Plane
FBTFTP: an opensource framework to build dynamic tftp servers
Performance optimization 101 - Erlang Factory SF 2014
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
Flink Forward Berlin 2017: Andreas Kunft - Efficiently executing R Dataframes...
OpenZFS at LinuxCon
HBase Coprocessors @ HUG NYC
Nov. 4, 2011 o reilly webcast-hbase- lars george
Flink Forward Berlin 2017: Patrick Lucas - Flink in Containerland
0.5mln packets per second with Erlang
Ad

Viewers also liked (9)

PPTX
ONOS intent introduction
PPTX
NSCTF
PPTX
Ryu dynamic loader
PPTX
20161119 SDNDS-TW Meetup
PPTX
2015 COSCUP SDN Workshop -- SDN Quick Start
PPTX
Ryu SDN-IP
PDF
P4: Programming Protocol-Independent Packet Processor
PDF
2016 COSCUP SDN Introduction
PDF
2016 COSCUP ONOS
ONOS intent introduction
NSCTF
Ryu dynamic loader
20161119 SDNDS-TW Meetup
2015 COSCUP SDN Workshop -- SDN Quick Start
Ryu SDN-IP
P4: Programming Protocol-Independent Packet Processor
2016 COSCUP SDN Introduction
2016 COSCUP ONOS
Ad

Similar to JS introduction (20)

PDF
fundamentals-of-java-script-a-comprehensive-guide.pdf
PPTX
Intro to Javascript
PPT
17javascript.ppt17javascript.ppt17javascript.ppt
PPT
Java Script
PDF
Java Script
PPT
JavaScript Workshop
PDF
Basics of JavaScript
PPT
Java Script Programming on Web Application
PDF
JavaScript Getting Started
PPT
JavaScript ppt for introduction of javascripta
PPT
Presentation JavaScript Introduction Data Types Variables Control Structure
PDF
Hsc IT Chap 3. Advanced javascript-1.pdf
PPTX
JavaScript New Tutorial Class XI and XII.pptx
PPTX
Introduction_to_JavaScript..................pptx
PPT
17javascript.ppt
PPT
17javascript.ppt
PDF
Client sidescripting javascript
PPTX
Unit 3-Javascript.pptx
ODP
jsbasics-slide
PPT
JavaScript Tutorial
fundamentals-of-java-script-a-comprehensive-guide.pdf
Intro to Javascript
17javascript.ppt17javascript.ppt17javascript.ppt
Java Script
Java Script
JavaScript Workshop
Basics of JavaScript
Java Script Programming on Web Application
JavaScript Getting Started
JavaScript ppt for introduction of javascripta
Presentation JavaScript Introduction Data Types Variables Control Structure
Hsc IT Chap 3. Advanced javascript-1.pdf
JavaScript New Tutorial Class XI and XII.pptx
Introduction_to_JavaScript..................pptx
17javascript.ppt
17javascript.ppt
Client sidescripting javascript
Unit 3-Javascript.pptx
jsbasics-slide
JavaScript Tutorial

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Approach and Philosophy of On baking technology
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
A comparative analysis of optical character recognition models for extracting...
MYSQL Presentation for SQL database connectivity
MIND Revenue Release Quarter 2 2025 Press Release
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Review of recent advances in non-invasive hemoglobin estimation
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Programs and apps: productivity, graphics, security and other tools
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25-Week II
Approach and Philosophy of On baking technology
sap open course for s4hana steps from ECC to s4
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Unlocking AI with Model Context Protocol (MCP)
A comparative analysis of optical character recognition models for extracting...

JS introduction