Learn Enough to be Dangerous Flashcards
Who created JavaScript?
Brendan Eich
What is the purpose of JavaScript?
To write programs that execute on the web.
What is a function?
A piece of code that takes in arguments and performs some task with them.
What is a REPL?
a program that reads input, evaluates it, prints out the result (if any), and then loops back to the read step.
What are template literals?
Template literals are a way we can write strings with variables included using backticks and the ${variabe} syntax. ex ${firstName} ${lastName}
What does it mean if a function operates as a side effect? Give 2 examples
This mean that the function does something other than return a value.
Methods like .sort() and .reverse() mutates the arrays, permanently altering them.
What is a property?
a peice of data attached to an object
How are boolean values useful?
It is useful for control flow, allowing you to take actions based on the result of a comparison
Describe the &&(“and”), || (“or”), and !(“bang”) operators.
When comparing two booleans with &&, both have to be true for the combination to be true
|| lets us take action if either comparison (or both) is true
! (often pronounced “bang”), which just converts true to false and false to true
Define iteration
the practice of repeatedly stepping through an object one element at a time.
How would you access the last item in an array?
arr.slice(arr.length -1) or arr.slice(-1)
to access just the element arr.slice(-1)[0]
Describe 2 ways a number can be converted to a string
100.0.toString() or String(100.0)
The extra dot must be included so that JS treats the number as a float as it doesn’t handle integers very well
How would you convert a string into a number?
parseInt(n)
Whate is an object?
referring to the abstract idea of a collection of data (properties) and functions (methods). Within each object or key/value pairs. The keys are written as strings
(almost) everything in JavaScript is an object