How do you convert a number into a string?
Front
Active users
2
All-time users
2
Favorites
0
Last updated
1 month ago
Date created
Feb 17, 2021
Unsectioned
(6 cards)
How do you convert a number into a string?
.toString()
What to use when you want to know if a string begins with a value?
.startsWith()
How do you get rid of whitespace at the beginning and end of a string?
.trim()
Explain non-tagged template literals.
Within a string, you can insert (interpolate) code into a placeholder. The placeholder syntax is to use ${ }, the browser will execute what's inside the braces. Could be a function, variable, expression, whatever.
Use backticks instead of quotes to indicate the string is a template variable.
.substring() is weird and .slice() is better, why?
.substring uses the end index to ignore when .slice use of the end index includes the last character
What to use when you want to know if a string ends with a value?
.endsWith()
Array Methods
(10 cards)
With .includes(), if you use a from index of less than 0, what happens?
It takes the string length and subtracts the fromIndex. So, a string length of 5 with a fromIndex of -1 will calculate to be [4]
What would I use to see if a value is in a string?
.incluldes()
Add an item to the end of an array with?
.push()
What does .includes() return?
Boolean
is .includes() case sensitive?
Yep
If you mess up .includes() and put a fromIndex of greater than the string length, what happens?
return is false
What's the optional parameter in .includes()?
The fromIndex.
If you use a negative fromIndex on .includes() that is greater than the string length, what happens?
Nothing, it just searches the whole string.
What does .push() return?
The array length.
Does .includes() work only on strings?
No, it works on all array-like objects.
Objects
(1 card)
Object properties and methods are called differently, how so?
You don't use the parenthesis on a property.