0% found this document useful (0 votes)
5 views4 pages

Example Outline

The document provides an overview of JavaScript statements, syntax, comments, and operators. It outlines the structure of statements, the types of values (literals and variables), and the various operators used in JavaScript, including arithmetic, assignment, comparison, and logical operators. Additionally, it explains the use of comments in JavaScript and the rules for creating identifiers.

Uploaded by

wilhemfouetta6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Example Outline

The document provides an overview of JavaScript statements, syntax, comments, and operators. It outlines the structure of statements, the types of values (literals and variables), and the various operators used in JavaScript, including arithmetic, assignment, comparison, and logical operators. Additionally, it explains the use of comments in JavaScript and the rules for creating identifiers.

Uploaded by

wilhemfouetta6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Week: _2____________________ Name: _Joe Student ____

Assignment: JS Statements, Syntax, Comments, Operators Class: _CS 105-01 __ ___


Page 1 of 4 Date: __1/16/2019__ __

Ques NOTES:
JS Statements

Programs A list of instructions called statements.

Statements Made up of Values, Operators, Expressions, Keywords, and Comments.

; Statements are separated by a ;

White Space JavaScript ignores white space.

Line Length and Breaks You can put a statement on multiple lines, but it is best to do it after an operator.

Code Blocks Code block starts with { and ends with }.


Code inside the block will be executed together.

Keywords Tells what action will be performed.


Some of the keywords are:
Keyword Description

break Terminates a switch or a loop

continue Jumps out of a loop and starts at the top

debugger Stops the execution of JavaScript, and calls (if available) the debugging function

do ... while Executes a block of statements, and repeats the block, while a condition is true

for Marks a block of statements to be executed, as long as a condition is true

function Declares a function

if ... else Marks a block of statements to be executed, depending on a condition

return Exits a function

switch Marks a block of statements to be executed, depending on different cases

try ... catch Implements error handling to a block of statements

var Declares a variable


Week: _2____________________ Name: _Joe Student ____
Assignment: JS Statements, Syntax, Comments, Operators Class: _CS 105-01 __ ___
Page 2 of 4 Date: __1/16/2019__ __

Ques NOTES:
JS Syntax

What is syntax? Syntax is a set of rules


var a; // declares a variable
a = 5; // assigns the value 5 to the variable a
b = a + 10; // performs calculation and assigns value to b

Values Two types: Literals and Variables

Literals Fixed like numbers or strings.


100
“Hello”

Variable Values are stored in variable.


Var is used to declare a variable
var z;

Operators = is used to assign a value to a variable


z = 5;

Used to compute values (+ - * /)

Expressions Combination of values, variables and operators that compute to a value.

Identifiers Identifiers are variable names, keywords, function names and labels.
Must start with a letter, _ or $
All other characters must be letters, numbers, _ or $
They are case sensitive
Examples:
underscore_style
UpperCamelCase
lowerCamelCase

Character set JS uses the Unicode character set

JavaScript Comments
Single line comments. Anything after a // is ignored by JS
Comments Multi-line comments. Anything between /* and */ is ignored by JS
Week: _2____________________ Name: _Joe Student ____
Assignment: JS Statements, Syntax, Comments, Operators Class: _CS 105-01 __ ___
Page 3 of 4 Date: __1/16/2019__ __

Ques NOTES:

JavaScript Operators

Arithmetic Operators
Operator Description

+ Addition

- Subtraction

* Multiplication

/ Division

% Modulus (Division Remainder)

++ Increment

-- Decrement

Assignment Operators Operator Example Same As

= x=y x=y

+= x += y x=x+y

-= x -= y x=x-y

*= x *= y x=x*y

/= x /= y x=x/y

%= x %= y x=x%y

+ will concatenate two strings


String Operators
txt1 = “David”
txt2 = “Jones”
txt3 = txt1 + “ “ + txt2

+= can also be used to concatenate without the need for a new variable.
Week: _2____________________ Name: _Joe Student ____
Assignment: JS Statements, Syntax, Comments, Operators Class: _CS 105-01 __ ___
Page 4 of 4 Date: __1/16/2019__ __

Ques NOTES:
Adding Strings and Adding a string and a number results in a string.
Numbers Adding a number and a string results in a number.

“10” + 6 => “106”


6 + “10” => 16

Comparison Operators Operator Description

== equal to

=== equal value and equal type

!= not equal

!== not equal value or not equal type

> greater than

< less than

>= greater than or equal to

<= less than or equal to

? ternary operator

Logical Operators
Operator Description

&& logical and

|| logical or

! logical not

You might also like