Save
VARIABLES, COMMENTS, FUNCTIONS
Save
Share
Learn
Content
Leaderboard
Learn
Created by
G16-Reyes, Shenel
Visit profile
Cards (14)
Single line comment
Starts
with
a
/
/
Multi-line comment
Starts
with
/
*
and
ends
with
*
/
Variable
A
value
that can
change
,
depending
on the
conditions
or on the
information
passed
on to the
program
Keywords for variable declaration
var
let
const
None
When to use
var
If you
want
your
code
to
run
in
older
browsers
It is used in
all
javascript
code
from
1995
to
2015
When to use let
Variables
defined with let cannot be
redeclared
It must be
declared before
use
It has a
block
scope
When to use const
Variables
defines with const cannot be
redeclared
It cannot be
reassigned
It has a
block scope
Variable naming rules
Names can contain
letters
,
digits
,
underscores
, and
dollar signs
Names must begin with a
letter
Names can also begin with
$
and
_
Names are
case sensitive
Reserved words
cannot
be used as
names
Function
A
block
of
code
designed to perform a particular
task
Defined with the
function
keyword
,
followed
by
a
name
,
followed
by
a
parentheses
Parameters
Listed inside the
parentheses
(
)
in
the
function
definition
Arguments
The
values
received
by the
function
when it is
invoked
Function
invocation
When an
event
occurs
When it is
invoked
(
called
) from JavaScript code
Automatically
(
self-invoked
)
Return keyword
Function
open
compute
return
value
The returned value is returned back to the
caller
Why use functions
To
reuse
the code
To avoid
repetition
of codes
To use the same code with different
arguments
for different
outcomes