Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

JAVASCRIPT CHEATSHEET

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
04-08-2024
Written in
2024/2025

a concise reference guide designed to help developers quickly recall essential JavaScript syntax, functions, and concepts. It’s particularly useful for both new and experienced programmers who need a quick refresher or need to look up specific code snippets

Show more Read less
Institution
Course

Content preview

JavaScript Survival Kit Cheat Sheet



About this document  Variables - Explained (cont)  Objects - Explained

This cheat-​sheet explains the most Why use variab​les? What is an object?
important parts of the JavaScript language,
Use them to "​rem​emb​er" things in the program. If a variable is a "​box​" which can hold a
defines some key terms and shows the
Sometimes, the collection of all variables value, then an object is a box of boxes,
syntax through small examples.
(every​thing the program remembers) is called the holding many values - each of which is a
However, it's no substitute for proper
state of the program. prope​rty.
studying - you can't learn to program off of
a cheat sheet (sorry!).  Where to read more What is a proper​ty?

Read the section "​Var​iab​les​" at: A property is some small part of an object
 Variables - Explained eloquentjavascript.net/02_program_structure.html which holds some data (e.g. string ) or a
Funct​ion. Each property has an
What is a variab​le?
 Variables - Examples ident​i​f​ier, just like variables.
A variable is a storage location, a
"​​bo​x"​ , which we associate with a name Define a variable  Where to read more
(an identi​f​ ier). The variable can hold a eloquentjavascript.net/04_data.html - The
var name = "Adalina";
single value and its value may be introd​uction and the paragraphs
NB - subsequent examples assume we have
changed "​Pro​per​tie​s" and "​Obj​ect​s"
defined this variable.
What is an identi​fier?
Retrieve the variable's value
It's the "​​na​m​e"​ affixed the variable. Later  Objects - Examples
Simply refer to the variable's identifier:
on, whether updating or retrieving its Define an object
console.log(name);
value, we'll use refer to the variable by
its identi​f​ ier. is (in this case) the same as: Define an object with two properties whose
console.log("Adalina"); identi​fiers are "​nam​e" and "​spe​cie​s":
What can a variable hold? var my_pet = {
Update the variable's value
Any string, number, boolean , name: "spot",
array, object or Funct​ion. name = "Emma"; species: "dog"
NB - The syntax is the same as defining the }
variable, sans the var keyword!
NB Subsequent examples will assume we
start with this object.
NB It isn't necessary to define a variable to
hold the array (but you almost always will).



By pseud Published 9th March, 2016. Sponsored by CrosswordCheats.com
Last updated 11th March, 2016. Learn to solve cryptic crosswords!
Page 1 of 6. http://crosswordcheats.com

, JavaScript Survival Kit Cheat Sheet



 Objects - Examples (cont) Compar​isons (cont) Conditions - False & True (cont)

Retrieve a property x > y true if x is greater than y` Where are conditions used?

Get the value of the name property: x < y true if x is less than y Conditions determine which code block to
my_pet["name"] evaluate in if-sta​tements and when to
!x true if x is false
or terminate a loop.
x && true if both x and y are true
my_pet.name
y  Functions - Explained
Update a property
x || true if either (or both) x or y are What is a functi​on?
To change the value of the name property
y true
Functions group code together into a block
(i.e. rename our pet):
which is given a name (an ident​ifi​er).
my_pet["name"] = "sparky";
Conditions - False & True Functions often accept arguments to modify
or
their behaviour.
my_pet.name = "​spa​rky​"; What's a condit​ion?

A condition is really just an expres​sion. What is an argume​nt?
Add a property
When we use an expression as a condition, Think of function arguments as variables
my_pe​t["b​ree​d"] = 'bulldog'; we're not interested in its value, but whether which are defined & available to the code
or or not that value is truthy. inside the function. The value of an
my_pet.breed = 'bulldog'; argument is determined by the point the
What's a truthy value?
NB adding​/up​dating a property uses the function is called and the argume​nt(s) is
In JavaSc​ript, all but 6 values are truthy , supplied.
same syntax - if the property didn't exist, it is
added. that is, unless your condi​tion evaluates to
Why use functi​ons?
one of those 6 values, the code guarded by
Remove a property the if-block will be run. Functions are the primary way of defining
To remove the species property: more complex or specific actions than is
What are the falsy values?
delete my_pet["species"]; built into JavaScript and to organise code.
These 6 values will cause the condition to In other words - functions are handy when
or
fail and the code it guards to be skipped: we wish to use a piece of code more than
delete my_pet.sp​ecies;
• false once.
• 0 - (the number zero)
 Where to read more
Compar​isons • "" - (the empty string)
eloquentjavascript.net/03_functions.html
x === true if x is equal to y • null

y • undefined
• NaN - not a number
x !== true if x is different from y
y

x >= y true if x is greater than, or equal to
y

x <= y true if x is less than, or equal to y



By pseud Published 9th March, 2016. Sponsored by CrosswordCheats.com
Last updated 11th March, 2016. Learn to solve cryptic crosswords!
Page 2 of 6. http://crosswordcheats.com

Written for

Course

Document information

Uploaded on
August 4, 2024
Number of pages
6
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
kimblegavane1

Get to know the seller

Seller avatar
kimblegavane1 (self)
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
5
Last sold
-
STUDY CHEATS AND SOLUTIONS 99

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions