Javascript Flashcards
What is JavaScript?
High level language that humans understand, that can be broken down into basic computer language (binary code)
What is the DOM
Document object model = everything in inspector is NOT the HTML / CSS. It is the RENDERING of these files.
You can manipulate the DOM (rendering of files) via JavaScript.
What happens to the DOM when you refresh a webpage?
the DOM (document object model) resets completely and starts from scratch
How does JavaScript affect our HTML / CSS codes.
JavaScript manipulates and changes the way a DOM is rendered, not the files. JS works on the browser itself.
What’s an event listener?
Sensors in your DOM that respond to specific stimulus and activate a specific program/code action in response.
4 key aspects to know in JavaScript
Variables, conditionals, functions, loops
What are variables
What we can use to tell program to store/remember a value for use later on.
What is a declaration
What we use to create a space in memory
Ex. “ let age “
What’s an assignment
Assignment = action of setting a unit/info to a declaration/memory bucket.
Ex . Age = 25
What 2 steps of a variable? Give example
- Create a space in memory (declaration)
- Assign a value (assignment)
Let age = 25
What are variable conventions? Ex. Camel case
The way to write variables.
Camel case = first word low caps
Next words = upper case first letters
What two common types of data can you store in your variables?
Numbers
Strings (pieces of text)
What are strings? How to write them?
Piece of text, surrounded by double quotes, single quotes, or ticks (all preference)
What you use on outside CANT be used on inside:
Example : ‘They “purchased” it’
If you want to use double quotes, how to escape that?
Put back slash \ before each quote:
“They \”purchased\” it”
What 2 kinds of numbers in JavaScript?
Integers (isn’t) : 29 (whole numbers)
Float: 5.19398 (number with decimal places)
What signs for multiply? Division? Modulus?
Multiply *
Divide /
Modulus %
What is 10 mod 4?
- (4 goes into 10 twice with 2 left over)
Mod = modulus = remainders.
What are conditionals in JavaScript?
If - condition = activate program
What does “ x = = 3 “ mean? How is it different from x = = = 3
Two = means equal in VALUE
Three = means equal in Value and TYPE
What does ! Mean in “ x ! = 8
! = not
X doesn’t not equal 8
What is conditional syntax?
If ( condition is true ) {
/ / do cool stuff
}
How to program multiple conditionals : if the first doesn’t work..
If ( condition is true ) {
Do this cool stuff
} else if (condition is true ) {
Do this other cool stuff )
} else {
Do default stuff
}
Const vs let
Const = Constance (never changing variable_)
Let = variable that can change or be re-assigned
How to write a double conditional? (2 conditions at one time)
If ( condition 1 && condition 2 ) {
Action
}
Must use 2 ampersands
How to write a double (either or) condition
If ( condition 1 || condition 2 ) {
Action
}
What is pseudo code and why is it important?
Being able to talk out what you want your code to do, and then coding it.
Allows you to code in any language.
How to declare and assign multiple variables at once?
Let user = ‘ John ‘
, age = 25
, message = ‘ yellow ‘ ;