Javascript / JQuery / OOP / JSON (junior) Flashcards
What is a variable?
Where data can be stored!
Why are variables useful?
variable can be used to store and recall information through-out a program.
What two special characters can a variable begin with?
$ _
How do you declare a variable?
using a variable identifier
How do you assign a value to a variable?
= next to variable name
Are variables case sensitive?
yes
Which words cannot be used as variable names?
keywords (var, function, if) numbers..
What is a string?
Sub-series of characters that comes inside two ‘ or “
What is the string concatenation operator?
+
What is the difference when it comes to using single quotes or double quotes ( ‘ ‘ or “ “ )?
no difference in functionality
How do you escape quotation characters?
\ before the quote.
What is a number in JavaScript?
an integer
What is an arithmetic operator?
Mathematical function that takes two operands and performs a calculation on them.
Name four of the arithmetic operators?
add subtract
What is the order of execution?
PEMDAS
What is a boolean?
true / false
What is a comparison operator?
< = >
What is a comparison operator?
< = > == ===
What is a function?
Series of statements that are grouped together because they perform a specific task.
Why are functions useful?
you can reuse the function (rather than repeating the same set of statements).
How do you call a function?
function name followed by () with any argument inside.
What are the parts of a function definition?
function keyword, function name and code bloke inside curly braces.
What is the difference between a parameter and an argument?
methods are same as functions, except they’re created inside (and are part of) an object.
What is the difference between a parameter and an argument?
parameters are placeholders for values in function and arguments are the values when calling the function.
Why is it important to understand truthy and falsy values?
They allow decision making
Why is the typeof an object null?
it’s a bug!
What is the difference between null and undefined?
an undefined variable has no value, null has no specific value assigned to it but has a placeholder and act as an object ready to be assigned with a value.
What is the proper syntax for using the or operator?
|| double pipe
Why do you want to avoid using == for comparison?
== doesn’t check on type similarity!
Do all if statements require an else statement?
no
What is the primary use case for switches?
comparing any individual value against a range of other individual values.
Does the default case have to be at the bottom of the switch statement?
to get executed after checking for all possible cases
Does the default case have to be at the bottom of the switch statement?
no!
What is an object in JavaScript?
A set of variables and functions grouped together.
How do you create an object literal?
declaring a variable with a name for object, equal sign, curly braces and key/value for each property or method in between separated by comma
What is a property in relation to JavaScript objects?
A set of key and value.
When should you use bracket notation over dot notation with objects?
any time there’s illegal property name dot notation needs to be used to access the value
How do you remove a property from an object?
delete operator.
What is an array in JavaScript?
list of data
How do you create an array literal?
assigning data in brackets
What are the keys for the values inside an array?
index numbers.
Arrays have a property named length. Because arrays have a properties, what other data structure are they similar to?
objects
What are some good use cases for using objects inside arrays?
online shopping card with list of items and their properties (price, ..)
What is the primary advantage to storing your selected elements in a variable?
so they can be reused every time without a need to target them again
Why might you need JavaScript to modify the DOM after the page loads?
adjustments and updates based on user behavior
How can you better prepare when writing HTML for DOM manipulation in your JavaScript code?
setting better structure and placement for items that are going to be manipulated
What are the differences between innertext and textContent?
textContent gets the content of all elements, including and <style> elements. In contrast, innerText only shows “human-readable” elements.</style>
What datatype are the values you remove from a text input?
strings
Why is it so important to be able to dynamically update text?
to be able to updated the text content based on user interaction
What are some of the drawbacks of HTML Event Handler Attributes?
readibility, seperating html and JS codes
Why is the Window.event property to be avoided in new code?
window object gets rewrite/change with every change
What is the difference between the getElementById() method and the querySelector() method?
getElementById() is only for ids, querySelector() can be used to target any element
Who passes in the event object into the handleClick callback function?
JS
Does a callback function require a name?
no, but would be better to set name to describe the function and reusability
What is the purpose of a loop?
to rerun a code block while their condition is true
Why might there be different kinds of loops?
depending on the condition required to run a code block
What is the purpose of a conditional expression as it relates to loops?
to update the condition set every time loop runs the code block
Could a loop potentially go on forever?
yes!
Could a loop never start?
yes!
How do you target the value of a property in an object.
using bracket
When should you use a for in loop?
looping over an object
What is the difference between the parentNode and parentElement properties?
parentElement is the actual element, parentNode could be any item.