Javascript Fundamentals Flashcards
How do you declare a variable?
let name = value
What are the rules for naming variables?
can’t start with a number
can’t contain special characters except for $ and _
What are operators, operands, and operations?
Operators - the symbol in an operation
Operands - The numbers
Operations - tho sum as a whole
What is concatenation and what happens when you add numbers and strings together?
String concatonation is the joining of multiple strings into one string
What is the difference between == and ===?
Double equals (==) is a comparison operator, which transforms the operands having the same type before comparison.
So, when you compare string with a number, JavaScript converts any string to a number. An empty string is always converts to zero. A string with no numeric value is converts to NaN (Not a Number), which returns false.
What is === in JavaScript?
=== (Triple equals) is a strict equality comparison operator in JavaScript, which returns false for the values which are not of a similar type. This operator performs type casting for equality. If we compare 2 with “2” using ===, then it will return a false value.
What are operator precedence values?
BODMAS
What are the increment/decrement operators?
++
–
What is the difference between prefixing and post-fixing the increment/decrement operators?
the postfix form counter++ also increments counter but returns the old value (prior to increment
What is the “Unary +” Operator?
+=
What are the eight data types of javascript?
number - for numbers of any kind: integer or floating-point, integers are limited by ±253.
bigint - is for integer numbers of arbitrary length.
string - for strings. A string may have zero or more characters, there’s no separate single-character type.
boolean - for true/false.
null - for unknown values – a standalone type that has a single value null.
undefined - for unassigned values – a standalone type that has a single value undefined.
object - for more complex data structures.
symbol - for unique identifiers.
Which data type is NOT primitive?
object
What is the difference between single, double, and backtick quotes for strings?
There’s practically no difference between single and double quotes. Backtick quotes can be used to reference variables inside strings
Which type of quote lets you embed variables/expressions into a string?
backtick quote
How do you embed variables/expressions into a string?
${variable_name}
How do you escape characters in a string?
\
What is the difference between slice/substring/substr?
slice() extracts a part of a string and returns the extracted part in a new string.
substring() is similar to slice().
The difference is that substring() cannot accept negative indexes.
substr() is similar to slice().
The difference is that the second parameter specifies the length of the extracted part.
What are methods?
a method is a bit of functionality that is built into the language or into specific data types
What are the three logical operators and what do they stand for?
&& - AND
|| - OR
! - NOT
What are the comparison operators?
== - equality === - strict equality > - greater than < - less than >= - greater than or equal to <= - less than or equal to
What is nesting?
putting if/else statements inside other if/else statements
What are truthy and falsy values?
In JavaScript, truthy are expressions which evaluates to boolean true value and falsy evaluates to boolean false value.
What are the falsy values?
boolean false empty string undefined null NaN 0
What is the syntax for an if/else conditional?
if (conditon) { code; } else { code; }
What is the syntax for a switch statement?
switch (condition) { case evaluation: code; break; default: code;
What is the syntax for a ternary operator?
(condition ? exprIfTrue : exprIfFalse);
What is the relationship between null and undefined?
undefined means a variable has been declared but has not yet been assigned a value
null is an assignment value. It can be assigned to a variable as a representation of no value:
What are conditionals?
statements that control whether or not a block of code will execute, if/else statements for examplelet