Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Introduction to JavaScript
Apostolos Syropoulos
Xanthi, Greece
asyropoulos@yahoo.com
Introduction to JavaScript for members of the
Erasmus+ founded project GAMES
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Presentation Outline
1 Programming Languages
2 Basics of JavaScript
3 Expressions and Operators
4 Basic Commands
5 Defining New Functions
6 Finale
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Roughly, a computational task solves a computational problem.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Roughly, a computational task solves a computational problem.
What is computational problem?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Roughly, a computational task solves a computational problem.
What is computational problem?
Answer: A mathematical problem. But what is a mathematical
problem?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Roughly, a computational task solves a computational problem.
What is computational problem?
Answer: A mathematical problem. But what is a mathematical
problem?
Is the Seven Bridges of Königsberg a mathematical problem?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Roughly, a computational task solves a computational problem.
What is computational problem?
Answer: A mathematical problem. But what is a mathematical
problem?
Is the Seven Bridges of Königsberg a mathematical problem?
Are feelings computational processes? Can we download minds?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Roughly, a computational task solves a computational problem.
What is computational problem?
Answer: A mathematical problem. But what is a mathematical
problem?
Is the Seven Bridges of Königsberg a mathematical problem?
Are feelings computational processes? Can we download minds?
Back to business: Computers can calculate and enumerate and
that’s what we do with programming languages.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Programming Language?
A formalism (i.e., excessive adherence to prescribed forms) used
to instruct a computer to perform a computational task.
Roughly, a computational task solves a computational problem.
What is computational problem?
Answer: A mathematical problem. But what is a mathematical
problem?
Is the Seven Bridges of Königsberg a mathematical problem?
Are feelings computational processes? Can we download minds?
Back to business: Computers can calculate and enumerate and
that’s what we do with programming languages.
Niklaus Wirth did not like the term programming language.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
If by a sequence of commands, then it is a imperative one.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
If by a sequence of commands, then it is a imperative one.
If by objects and their interactions, then it is an object-oriented
one.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
If by a sequence of commands, then it is a imperative one.
If by objects and their interactions, then it is an object-oriented
one.
If by functions and their composition, then it is a functional one.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
If by a sequence of commands, then it is a imperative one.
If by objects and their interactions, then it is an object-oriented
one.
If by functions and their composition, then it is a functional one.
If by a set of sentences in logical form, then it is a logic
programming one.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
If by a sequence of commands, then it is a imperative one.
If by objects and their interactions, then it is an object-oriented
one.
If by functions and their composition, then it is a functional one.
If by a set of sentences in logical form, then it is a logic
programming one.
Specifying a programming language means to: describe its
syntax and its semantics.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
If by a sequence of commands, then it is a imperative one.
If by objects and their interactions, then it is an object-oriented
one.
If by functions and their composition, then it is a functional one.
If by a set of sentences in logical form, then it is a logic
programming one.
Specifying a programming language means to: describe its
syntax and its semantics.
Syntax: the way we arrange linguistic elements (commands) in a
sentence (a program).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Characteristics of Programming Languages
Programming languages are used to describe computational
tasks. There are several kinds.
If by a sequence of commands, then it is a imperative one.
If by objects and their interactions, then it is an object-oriented
one.
If by functions and their composition, then it is a functional one.
If by a set of sentences in logical form, then it is a logic
programming one.
Specifying a programming language means to: describe its
syntax and its semantics.
Syntax: the way we arrange linguistic elements (commands) in a
sentence (a program).
Semantics: what is the meaning (computational effect) of each
linguistic element (command).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java, JavaScript,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java, JavaScript, Perl,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java, JavaScript, Perl, Python,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java, JavaScript, Perl, Python, Ruby,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java, JavaScript, Perl, Python, Ruby, C#,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java, JavaScript, Perl, Python, Ruby, C#,
Haskell.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Some popular programming languages
Old languages: FORTRAN, COBOL, PL/1, Algol68, BASIC, LISP,
Pascal.
Timeless languages: C, C++, Ada, Prolog, SML.
Modern languages: Java, JavaScript, Perl, Python, Ruby, C#,
Haskell.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem. The solution is called an
algorithm.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem. The solution is called an
algorithm.
Programming is not something you learn by following a recipe or
a method.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem. The solution is called an
algorithm.
Programming is not something you learn by following a recipe or
a method.
Programming is both a craft and a science.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem. The solution is called an
algorithm.
Programming is not something you learn by following a recipe or
a method.
Programming is both a craft and a science.
It is a craft (or art!) because there are several rules of thumb that
one can follow to solve a problem.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem. The solution is called an
algorithm.
Programming is not something you learn by following a recipe or
a method.
Programming is both a craft and a science.
It is a craft (or art!) because there are several rules of thumb that
one can follow to solve a problem.
However, intuition plays a very important when solving a
problem.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem. The solution is called an
algorithm.
Programming is not something you learn by following a recipe or
a method.
Programming is both a craft and a science.
It is a craft (or art!) because there are several rules of thumb that
one can follow to solve a problem.
However, intuition plays a very important when solving a
problem.
A programmer is a scientist if mathematicians are scientists.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is Programming?
Programming is the mental activity by which we express the
solution to a given (mathematical) problem in some
programming language.
The difficult part is to solve the problem. The solution is called an
algorithm.
Programming is not something you learn by following a recipe or
a method.
Programming is both a craft and a science.
It is a craft (or art!) because there are several rules of thumb that
one can follow to solve a problem.
However, intuition plays a very important when solving a
problem.
A programmer is a scientist if mathematicians are scientists.
The realization of a solution requires the knowledge of common
techniques and practicers.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Outlining and structuring the solution.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Outlining and structuring the solution.
Selecting solution methods.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Outlining and structuring the solution.
Selecting solution methods.
Coding.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Outlining and structuring the solution.
Selecting solution methods.
Coding.
Debugging.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Outlining and structuring the solution.
Selecting solution methods.
Coding.
Debugging.
Testing and verifying.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Outlining and structuring the solution.
Selecting solution methods.
Coding.
Debugging.
Testing and verifying.
Documenting.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Steps Involved in Programming
Defining the problem.
Outlining and structuring the solution.
Selecting solution methods.
Coding.
Debugging.
Testing and verifying.
Documenting.
Maintaining the program.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is JavaScript?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is JavaScript?
It is an object-oriented programming language initially designed
and implemented by Netscape.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is JavaScript?
It is an object-oriented programming language initially designed
and implemented by Netscape.
The language is the most widely used language for client-side
scripting of web pages.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is JavaScript?
It is an object-oriented programming language initially designed
and implemented by Netscape.
The language is the most widely used language for client-side
scripting of web pages.
HTML5 and all relatively older versions of HTML support the
<script> element.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is JavaScript?
It is an object-oriented programming language initially designed
and implemented by Netscape.
The language is the most widely used language for client-side
scripting of web pages.
HTML5 and all relatively older versions of HTML support the
<script> element.
JavaScript can be used to make dynamic web pages.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is JavaScript?
It is an object-oriented programming language initially designed
and implemented by Netscape.
The language is the most widely used language for client-side
scripting of web pages.
HTML5 and all relatively older versions of HTML support the
<script> element.
JavaScript can be used to make dynamic web pages.
JavaScript and Java are object-oriented languages and this is
their only similarity.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Adding JavaScript Code to HTML Content
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Adding JavaScript Code to HTML Content
Here is how we can embed JavaScript code:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Adding JavaScript Code to HTML Content
Here is how we can embed JavaScript code:
<script>
JavaScript commands…
</script>
<noscript> WARNING</noscript>
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Adding JavaScript Code to HTML Content
Here is how we can embed JavaScript code:
<script>
JavaScript commands…
</script>
<noscript> WARNING</noscript>
Alternatively
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Adding JavaScript Code to HTML Content
Here is how we can embed JavaScript code:
<script>
JavaScript commands…
</script>
<noscript> WARNING</noscript>
Alternatively
…
<head>
<title>My Page</title>
<script src="common.js">
</script>
</head>
<body>
…
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
A Complete Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
A Complete Example
Here i a complete example:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
A Complete Example
Here i a complete example:
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title>Example</title>
</head><body>
<script>
document.write("Hello, net!")
</script>
<noscript>No JavaScript support.</noscript>
<p>That's all, folks.</p>
</body> </html>
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
A Complete Example
Here i a complete example:
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title>Example</title>
</head><body>
<script>
document.write("Hello, net!")
</script>
<noscript>No JavaScript support.</noscript>
<p>That's all, folks.</p>
</body> </html>
Open your text-editor, type the code, save the file and open it with
your browser.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Testing What We Will Learn
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Testing What We Will Learn
To test things please replace the JavaScript code with your code in the
following input file.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Testing What We Will Learn
To test things please replace the JavaScript code with your code in the
following input file.
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title>Example</title>
</head><body>
<script>
var x=5
x += 2
document.writeln(x)
</script>
</body> </html>
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Testing What We Will Learn
To test things please replace the JavaScript code with your code in the
following input file.
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title>Example</title>
</head><body>
<script>
var x=5
x += 2
document.writeln(x)
</script>
</body> </html>
Open your text-editor, type the code, save the file and open it with
your browser.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Values
A value can be…
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Values
A value can be…
A number, that is, a quantity like 41 or 3.14159.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Values
A value can be…
A number, that is, a quantity like 41 or 3.14159.
A Boolean (logical) value, that is, either the value true or the
value false. These values are answers to questions like 3 ≠ 4 or
3 < 4.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Values
A value can be…
A number, that is, a quantity like 41 or 3.14159.
A Boolean (logical) value, that is, either the value true or the
value false. These values are answers to questions like 3 ≠ 4 or
3 < 4.
A sequence of characters enclosed in quotation marks that are
known as strings.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Values
A value can be…
A number, that is, a quantity like 41 or 3.14159.
A Boolean (logical) value, that is, either the value true or the
value false. These values are answers to questions like 3 ≠ 4 or
3 < 4.
A sequence of characters enclosed in quotation marks that are
known as strings.
NB. A string must be enclosed in either single or double
quotation marks: "John's girlfriend." or
'Mary came!'.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Values
A value can be…
A number, that is, a quantity like 41 or 3.14159.
A Boolean (logical) value, that is, either the value true or the
value false. These values are answers to questions like 3 ≠ 4 or
3 < 4.
A sequence of characters enclosed in quotation marks that are
known as strings.
NB. A string must be enclosed in either single or double
quotation marks: "John's girlfriend." or
'Mary came!'.
The literal null, which denotes a no value.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Values
A value can be…
A number, that is, a quantity like 41 or 3.14159.
A Boolean (logical) value, that is, either the value true or the
value false. These values are answers to questions like 3 ≠ 4 or
3 < 4.
A sequence of characters enclosed in quotation marks that are
known as strings.
NB. A string must be enclosed in either single or double
quotation marks: "John's girlfriend." or
'Mary came!'.
The literal null, which denotes a no value.
The literal undefined, which denotes an undefined value.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
A variable is a name that is used to designate a value.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
A variable is a name that is used to designate a value.
In mathematics we write 𝜋 to designate the number
3.1415926535897 ….
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
A variable is a name that is used to designate a value.
In mathematics we write 𝜋 to designate the number
3.1415926535897 ….
A variable is actually the name of some storage location where a
value is stored.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
A variable is a name that is used to designate a value.
In mathematics we write 𝜋 to designate the number
3.1415926535897 ….
A variable is actually the name of some storage location where a
value is stored.
As time passes a variable may designate a different value.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
A variable is a name that is used to designate a value.
In mathematics we write 𝜋 to designate the number
3.1415926535897 ….
A variable is actually the name of some storage location where a
value is stored.
As time passes a variable may designate a different value.
Think of a process that counts objects. A variable standing for the
current number of objects will have different values at different
moments.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
A variable is a name that is used to designate a value.
In mathematics we write 𝜋 to designate the number
3.1415926535897 ….
A variable is actually the name of some storage location where a
value is stored.
As time passes a variable may designate a different value.
Think of a process that counts objects. A variable standing for the
current number of objects will have different values at different
moments.
The first character of the name of a variable must be a letter
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Variables
A variable is a name that is used to designate a value.
In mathematics we write 𝜋 to designate the number
3.1415926535897 ….
A variable is actually the name of some storage location where a
value is stored.
As time passes a variable may designate a different value.
Think of a process that counts objects. A variable standing for the
current number of objects will have different values at different
moments.
The first character of the name of a variable must be a letter
If there are more characters in a name they should be letters,
digits, or the symbol _ (underscore).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
A variable can be introduced with an assignment or a declaration.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
A variable can be introduced with an assignment or a declaration.
Assignment: variable = value.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
A variable can be introduced with an assignment or a declaration.
Assignment: variable = value.
Declaration: var variable.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
A variable can be introduced with an assignment or a declaration.
Assignment: variable = value.
Declaration: var variable.
Thus the command x = 3 assigns the value 3 to variable x.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
A variable can be introduced with an assignment or a declaration.
Assignment: variable = value.
Declaration: var variable.
Thus the command x = 3 assigns the value 3 to variable x.
The command x = x + 1 assigns the current value of x plus 1
to variable x.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
A variable can be introduced with an assignment or a declaration.
Assignment: variable = value.
Declaration: var variable.
Thus the command x = 3 assigns the value 3 to variable x.
The command x = x + 1 assigns the current value of x plus 1
to variable x.
The command var y declares variable y and its value becomes
undefined.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Using Variables
A variable can be introduced with an assignment or a declaration.
Assignment: variable = value.
Declaration: var variable.
Thus the command x = 3 assigns the value 3 to variable x.
The command x = x + 1 assigns the current value of x plus 1
to variable x.
The command var y declares variable y and its value becomes
undefined.
Find the final values of the various variables after these
commands have been executed.
x=4
y=6
z=2*x // * denotes multiplication
x=x+1 // + denotes addition
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
>= (greater than or equal to).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
>= (greater than or equal to).
Suppose that x = 5 and var y were just executed. Then,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
>= (greater than or equal to).
Suppose that x = 5 and var y were just executed. Then,
x == 5 evaluates to true;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
>= (greater than or equal to).
Suppose that x = 5 and var y were just executed. Then,
x == 5 evaluates to true;
x != 5 evaluates to false;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
>= (greater than or equal to).
Suppose that x = 5 and var y were just executed. Then,
x == 5 evaluates to true;
x != 5 evaluates to false;
x < 5 evaluates to false;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
>= (greater than or equal to).
Suppose that x = 5 and var y were just executed. Then,
x == 5 evaluates to true;
x != 5 evaluates to false;
x < 5 evaluates to false;
y == underfined evaluates to true;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Comparisons
𝐴 ⊜ 𝐵, where ⊜ is a comparison operator.
The standard comparison operators are:
== (equal to),
!= (not equal to),
< (less than),
> (greater than),
<= (less than or equal to), and
>= (greater than or equal to).
Suppose that x = 5 and var y were just executed. Then,
x == 5 evaluates to true;
x != 5 evaluates to false;
x < 5 evaluates to false;
y == underfined evaluates to true;
x <= 5 evaluates to true.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arrays
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arrays
An array is a special variable that can hold more than one value at
any moment.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arrays
An array is a special variable that can hold more than one value at
any moment.
Each value is assigned to an element of an array and one can refer
to an array by its index, which is a natural number (i.e., 0, 1, 2, etc.).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arrays
An array is a special variable that can hold more than one value at
any moment.
Each value is assigned to an element of an array and one can refer
to an array by its index, which is a natural number (i.e., 0, 1, 2, etc.).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arrays
An array is a special variable that can hold more than one value at
any moment.
Each value is assigned to an element of an array and one can refer
to an array by its index, which is a natural number (i.e., 0, 1, 2, etc.).
To create an array, write the name of the array, the symbol =, and
the values that will be stored to the array in square brackets
separated by comma:
coffees = ["French Roast", "Columbian",
"Kona"]
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arrays
An array is a special variable that can hold more than one value at
any moment.
Each value is assigned to an element of an array and one can refer
to an array by its index, which is a natural number (i.e., 0, 1, 2, etc.).
To create an array, write the name of the array, the symbol =, and
the values that will be stored to the array in square brackets
separated by comma:
coffees = ["French Roast", "Columbian",
"Kona"]
To print the second element of this array, use the following
command:
document.writeln(coffees[0])
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Strings
Strings consist of simple ASCII characters (i.e., the basic Latin
letters), escape sequences, or Unicode characters (i.e., any symbol
from most writing systems).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Strings
Strings consist of simple ASCII characters (i.e., the basic Latin
letters), escape sequences, or Unicode characters (i.e., any symbol
from most writing systems).
An escape sequence corresponds to a special character that
cannot be entered conventionally (e.g., the ESC key or the new
line character).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Strings
Strings consist of simple ASCII characters (i.e., the basic Latin
letters), escape sequences, or Unicode characters (i.e., any symbol
from most writing systems).
An escape sequence corresponds to a special character that
cannot be entered conventionally (e.g., the ESC key or the new
line character).
Escape sequences consist of a backslash followed by a single
letter.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Strings
Strings consist of simple ASCII characters (i.e., the basic Latin
letters), escape sequences, or Unicode characters (i.e., any symbol
from most writing systems).
An escape sequence corresponds to a special character that
cannot be entered conventionally (e.g., the ESC key or the new
line character).
Escape sequences consist of a backslash followed by a single
letter.
The character n) “prints” a new new line character.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Suppose that x = 5 and y=4 were just executed. Then,
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Suppose that x = 5 and y=4 were just executed. Then,
x+y evaluates to 9;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Suppose that x = 5 and y=4 were just executed. Then,
x+y evaluates to 9;
x-y evaluates to 1;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Suppose that x = 5 and y=4 were just executed. Then,
x+y evaluates to 9;
x-y evaluates to 1;
x*y evaluates to 20;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Suppose that x = 5 and y=4 were just executed. Then,
x+y evaluates to 9;
x-y evaluates to 1;
x*y evaluates to 20;
x/y evaluates to 1.25;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Suppose that x = 5 and y=4 were just executed. Then,
x+y evaluates to 9;
x-y evaluates to 1;
x*y evaluates to 20;
x/y evaluates to 1.25;
x%y evaluates to 1;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Arithmetic Operators
𝐴 ⊕ 𝐵, where ⊕ is an arithmetic operator.
The standard arithmetic operators are:
+ (plus, denotes addition),
- (minus, denotes subtraction),
* (times, denotes multiplication),
/ [the equivalent of obelus (÷) used for division],
% (remainder of integer division), and
** (exponentiation, that is, x**y stands for 𝑥 𝑦
).
Suppose that x = 5 and y=4 were just executed. Then,
x+y evaluates to 9;
x-y evaluates to 1;
x*y evaluates to 20;
x/y evaluates to 1.25;
x%y evaluates to 1;
x**y evaluates to 625.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
An assignment operator stores the value that is on the right of the
operator to the storage location designated by the variable on
the left of the operator.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
An assignment operator stores the value that is on the right of the
operator to the storage location designated by the variable on
the left of the operator.
The basic assignment operators are:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
An assignment operator stores the value that is on the right of the
operator to the storage location designated by the variable on
the left of the operator.
The basic assignment operators are:
The expression x += y is shorthand for x = x + y.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
An assignment operator stores the value that is on the right of the
operator to the storage location designated by the variable on
the left of the operator.
The basic assignment operators are:
The expression x += y is shorthand for x = x + y.
Similarly, x -= y is shorthand for x = x - y;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
An assignment operator stores the value that is on the right of the
operator to the storage location designated by the variable on
the left of the operator.
The basic assignment operators are:
The expression x += y is shorthand for x = x + y.
Similarly, x -= y is shorthand for x = x - y;
x *= y is shorthand for x = x * y;
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
An assignment operator stores the value that is on the right of the
operator to the storage location designated by the variable on
the left of the operator.
The basic assignment operators are:
The expression x += y is shorthand for x = x + y.
Similarly, x -= y is shorthand for x = x - y;
x *= y is shorthand for x = x * y;
x /= y is shorthand for x = x / y; and
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Assignment Operators
An assignment operator stores the value that is on the right of the
operator to the storage location designated by the variable on
the left of the operator.
The basic assignment operators are:
The expression x += y is shorthand for x = x + y.
Similarly, x -= y is shorthand for x = x - y;
x *= y is shorthand for x = x * y;
x /= y is shorthand for x = x / y; and
x %= y is shorthand for x = x % y.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x--
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x-- Yields the value of x and then decreases the value of x by
one.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x-- Yields the value of x and then decreases the value of x by
one.
++x
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x-- Yields the value of x and then decreases the value of x by
one.
++x Increases the value of x by one and yields this new value.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x-- Yields the value of x and then decreases the value of x by
one.
++x Increases the value of x by one and yields this new value.
--x
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x-- Yields the value of x and then decreases the value of x by
one.
++x Increases the value of x by one and yields this new value.
--x Decreases the value of x by one and yields this new value.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x-- Yields the value of x and then decreases the value of x by
one.
++x Increases the value of x by one and yields this new value.
--x Decreases the value of x by one and yields this new value.
-x
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
More Arithmetic Operators
x++ Yields the value of x and then increases the value of x by
one.
x-- Yields the value of x and then decreases the value of x by
one.
++x Increases the value of x by one and yields this new value.
--x Decreases the value of x by one and yields this new value.
-x Yields the opposite of x.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Boolean Operators
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Boolean Operators
x && y
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Boolean Operators
x && y = true only if both x and y evaluate to true.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Boolean Operators
x && y = true only if both x and y evaluate to true.
x || y
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Boolean Operators
x && y = true only if both x and y evaluate to true.
x || y = true if either x or y evaluate to true.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Boolean Operators
x && y = true only if both x and y evaluate to true.
x || y = true if either x or y evaluate to true.
! x
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Boolean Operators
x && y = true only if both x and y evaluate to true.
x || y = true if either x or y evaluate to true.
! x = true if x evaluates to false, true otherwise.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
About Commands in General
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
About Commands in General
A command is an instruction given by a user telling a computer to
do something.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
About Commands in General
A command is an instruction given by a user telling a computer to
do something.
Commands are put together by a programmer to achieve a
specific task.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
About Commands in General
A command is an instruction given by a user telling a computer to
do something.
Commands are put together by a programmer to achieve a
specific task.
The basic commands of the language are:
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
About Commands in General
A command is an instruction given by a user telling a computer to
do something.
Commands are put together by a programmer to achieve a
specific task.
The basic commands of the language are:
Conditional commands: if...else and swicth.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
About Commands in General
A command is an instruction given by a user telling a computer to
do something.
Commands are put together by a programmer to achieve a
specific task.
The basic commands of the language are:
Conditional commands: if...else and swicth.
Repetition commands: for, while, do...while, a labeled
command (used in repetition commands without being such a
command), the break command and the continue command.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
About Commands in General
A command is an instruction given by a user telling a computer to
do something.
Commands are put together by a programmer to achieve a
specific task.
The basic commands of the language are:
Conditional commands: if...else and swicth.
Repetition commands: for, while, do...while, a labeled
command (used in repetition commands without being such a
command), the break command and the continue command.
Comments.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The if command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The if command
if (condition){
commands
}
if (condition){
commands A
}
else{
commands B
}
Form (a) Form (b)
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The if command
if (condition){
commands
}
if (condition){
commands A
}
else{
commands B
}
Form (a) Form (b)
Example
if(3>2){
document.write("okey!")
else{
document.write("problem!")
}
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The switch Command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The switch Command
switch (expression){
case label1:
command1;
break;
case label2:
command2;
break;
…
default: commandN;
}
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The for Command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The for Command
for (initialization; condition; inc.-dec.){
commands
}
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The for Command
for (initialization; condition; inc.-dec.){
commands
}
Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The for Command
for (initialization; condition; inc.-dec.){
commands
}
Example
var sum = 0;
for(i=1; i<=100; i++){
sum += i;
}
document.write("<p> 1+2+...+100 = ")
document.write(sum); document.write("</p>")
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The do-while Command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The do-while Command
do {
commands
} while (condition)
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The do-while Command
do {
commands
} while (condition)
Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The do-while Command
do {
commands
} while (condition)
Example
i=0;
do{
i++;
document.writeln(i);
}while (i<=5);
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The while Command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The while Command
while (condition){
commands
}
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The while Command
while (condition){
commands
}
Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The while Command
while (condition){
commands
}
Example
i=1;
while (i<=5){
document.writeln(i);
i++;
};
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Labels
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Labels
label: command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Labels
label: command
Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Labels
label: command
Example
var str = "";
loop1: for (var i = 0; i < 5; i++) {
if (i == 1) {
continue loop1;
}
str = str + i;
}
documemt.write(str);
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Labels
label: command
Example
var str = "";
loop1: for (var i = 0; i < 5; i++) {
if (i == 1) {
continue loop1;
}
str = str + i;
}
documemt.write(str);
Note that numbers can be automatically transformed into strings.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The break command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The break command
break or break label
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The break command
break or break label
Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The break command
break or break label
Example
for (i=0; i < a.length; i++) {
if (a[i] == theValue) {
break;
}
}
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The continue command
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The continue command
continue or continue label
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The continue command
continue or continue label
Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
The continue command
continue or continue label
Example
i = 0
n = 0
while (i < 5) {
i++
if (i == 3) {
continue
}
document.write(n); document.write(" ")
n += i
}
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Function?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Function?
A set is a collection of things (e.g., numbers, objects, people, etc.).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Function?
A set is a collection of things (e.g., numbers, objects, people, etc.).
A function is a relation between the elements of two or more sets.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Function?
A set is a collection of things (e.g., numbers, objects, people, etc.).
A function is a relation between the elements of two or more sets.
A function from a set 𝐴 to a set 𝐵 maps every element of 𝐴 to one
and only one element of 𝐵.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Function?
A set is a collection of things (e.g., numbers, objects, people, etc.).
A function is a relation between the elements of two or more sets.
A function from a set 𝐴 to a set 𝐵 maps every element of 𝐴 to one
and only one element of 𝐵.
To define a function mathematically, we have to write something
like minus(𝑥) = −𝑥.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Function?
A set is a collection of things (e.g., numbers, objects, people, etc.).
A function is a relation between the elements of two or more sets.
A function from a set 𝐴 to a set 𝐵 maps every element of 𝐴 to one
and only one element of 𝐵.
To define a function mathematically, we have to write something
like minus(𝑥) = −𝑥.
The letter 𝑥 is called a parameter, while the 5 in minus(5) is called
argument.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
What is a Function?
A set is a collection of things (e.g., numbers, objects, people, etc.).
A function is a relation between the elements of two or more sets.
A function from a set 𝐴 to a set 𝐵 maps every element of 𝐴 to one
and only one element of 𝐵.
To define a function mathematically, we have to write something
like minus(𝑥) = −𝑥.
The letter 𝑥 is called a parameter, while the 5 in minus(5) is called
argument.
In computer jargon we say a function returns a value and we
mean the value that the function maps its argument.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions
To define a function we first type the word function.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions
To define a function we first type the word function.
Then, the name of the function, which should be no different
than a variable name.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions
To define a function we first type the word function.
Then, the name of the function, which should be no different
than a variable name.
Α sequence of parameters separated by comma surrounded by
parantheses.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions
To define a function we first type the word function.
Then, the name of the function, which should be no different
than a variable name.
Α sequence of parameters separated by comma surrounded by
parantheses.
Τhe body of the function that is used to map the arguments to a
value or values. Typically, the body contains many commands
and is surrounded by curly brackets.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions
To define a function we first type the word function.
Then, the name of the function, which should be no different
than a variable name.
Α sequence of parameters separated by comma surrounded by
parantheses.
Τhe body of the function that is used to map the arguments to a
value or values. Typically, the body contains many commands
and is surrounded by curly brackets.
Example:
function square(number){
return number*number
}
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions cont.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions cont.
Command return interrupts the execution and forces the
function to map the argument to what follows this word.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions cont.
Command return interrupts the execution and forces the
function to map the argument to what follows this word.
We can use the function we defined in the previous slide as
follows:
x = square(3)
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions cont.
Command return interrupts the execution and forces the
function to map the argument to what follows this word.
We can use the function we defined in the previous slide as
follows:
x = square(3)
Obviously, this command assigns the number 9 to variable x
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions cont.
Command return interrupts the execution and forces the
function to map the argument to what follows this word.
We can use the function we defined in the previous slide as
follows:
x = square(3)
Obviously, this command assigns the number 9 to variable x
Functions in JavaScript can be recursive, that is, they can be
defined in terms of themselves.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
New Functions cont.
Command return interrupts the execution and forces the
function to map the argument to what follows this word.
We can use the function we defined in the previous slide as
follows:
x = square(3)
Obviously, this command assigns the number 9 to variable x
Functions in JavaScript can be recursive, that is, they can be
defined in terms of themselves.
However, I will not discuss them here.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling
An event is an action or occurrence that happens in the system
one is programming.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling
An event is an action or occurrence that happens in the system
one is programming.
A system informs programs about events and so one can
program then to respond to them in some way if desired.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling
An event is an action or occurrence that happens in the system
one is programming.
A system informs programs about events and so one can
program then to respond to them in some way if desired.
If a user clicks a button on a web page, a program might respond
to that action by displaying an information box.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling
An event is an action or occurrence that happens in the system
one is programming.
A system informs programs about events and so one can
program then to respond to them in some way if desired.
If a user clicks a button on a web page, a program might respond
to that action by displaying an information box.
In order to define an event handler we need something that will
trigger an event.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling
An event is an action or occurrence that happens in the system
one is programming.
A system informs programs about events and so one can
program then to respond to them in some way if desired.
If a user clicks a button on a web page, a program might respond
to that action by displaying an information box.
In order to define an event handler we need something that will
trigger an event.
When a user moves the mouse over an area, an event happens.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling
An event is an action or occurrence that happens in the system
one is programming.
A system informs programs about events and so one can
program then to respond to them in some way if desired.
If a user clicks a button on a web page, a program might respond
to that action by displaying an information box.
In order to define an event handler we need something that will
trigger an event.
When a user moves the mouse over an area, an event happens.
To define an event handler: the name inside a tag followed by an
equal sign, followed by JavaScript code that will be invoked when
the event associated with the handler happens.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling Example
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling Example
<input type="button" value="Calculate"
onClick="compute(this.form)">
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling Example
<input type="button" value="Calculate"
onClick="compute(this.form)">
When button is clicked, then function compute is called.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling Example
<input type="button" value="Calculate"
onClick="compute(this.form)">
When button is clicked, then function compute is called.
This function takes as argument the name of a form.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling Example
<input type="button" value="Calculate"
onClick="compute(this.form)">
When button is clicked, then function compute is called.
This function takes as argument the name of a form.
But what is a form and what kind of name it has?
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling Example
<input type="button" value="Calculate"
onClick="compute(this.form)">
When button is clicked, then function compute is called.
This function takes as argument the name of a form.
But what is a form and what kind of name it has?
A form contains radio buttons, input elements, etc., and buttons.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Event Handling Example
<input type="button" value="Calculate"
onClick="compute(this.form)">
When button is clicked, then function compute is called.
This function takes as argument the name of a form.
But what is a form and what kind of name it has?
A form contains radio buttons, input elements, etc., and buttons.
A user presses a button and data are processed either locally or
remotely.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DOM
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DOM
All HTML elements can have an id attribute that has as value
some string.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DOM
All HTML elements can have an id attribute that has as value
some string. This is can be its name.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DOM
All HTML elements can have an id attribute that has as value
some string. This is can be its name.
<h1 id="myHeader">Hello World!</h1>
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DOM
All HTML elements can have an id attribute that has as value
some string. This is can be its name.
<h1 id="myHeader">Hello World!</h1>
var a = document.getElementById("myHeader");
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DOM
All HTML elements can have an id attribute that has as value
some string. This is can be its name.
<h1 id="myHeader">Hello World!</h1>
var a = document.getElementById("myHeader");
<h1 id="xx">Hello User!</h1>
<script>
setTimeout(function(){
document.getElementById("xx").innerHTML =
"Bye User!";},
10000);
</script>
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DOM
All HTML elements can have an id attribute that has as value
some string. This is can be its name.
<h1 id="myHeader">Hello World!</h1>
var a = document.getElementById("myHeader");
<h1 id="xx">Hello User!</h1>
<script>
setTimeout(function(){
document.getElementById("xx").innerHTML =
"Bye User!";},
10000);
</script>
All this is possible because of the Document Object Model (DOM).
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Finale
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Finale
I explained what programming languages are.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Finale
I explained what programming languages are.
I introduced the basics of JavaScript.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Finale
I explained what programming languages are.
I introduced the basics of JavaScript.
I discussed expressions and operators.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Finale
I explained what programming languages are.
I introduced the basics of JavaScript.
I discussed expressions and operators.
I presented the basic commands
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Finale
I explained what programming languages are.
I introduced the basics of JavaScript.
I discussed expressions and operators.
I presented the basic commands
I showed how to defined new commands and us them to handle
events.
Introduction to
JavaScript
Syropoulos
Programming
Languages
Basics of
JavaScript
Expressions and
Operators
Basic Commands
Defining New
Functions
Finale
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Finale
I explained what programming languages are.
I introduced the basics of JavaScript.
I discussed expressions and operators.
I presented the basic commands
I showed how to defined new commands and us them to handle
events.
Thank you very much for your attention!

JavaScript for pupils