Terminology & Definitions
-
Name the three ways to declare a variable?
var, const and let.
-
Which of the three variable declarations should you avoid and why?
var because it is considered a bad practice.
-
What rules should you follow when naming variables?
The first character must not be a number.
The name must contain only letters, numbers, "_" or "$" symbol.
-
What should you look out for when using the "+" operator with numbers and strings?
Addition operator produces the sum for numbers or concatenation for strings.
Unary plus operator before an operand convert it into a number.
-
How does the "%"" operator work?
Remainder operator returns the remainder left over when one operand is divided by a second operand.
-
Explain the difference between == and ===
Strict equality operator (===) checks whether its two operands are equal including data type.
Equality operator (==) checks whether its two operands are equal. It attempts to convert and compare operands that are of different types.
-
When would you receive a NaN result?
Not a number is a Number property and its value is anything but a number. You receive it when you can not to parse a parameter in a number.
-
How do you increment and decrement a number?
Using ++ or -- operators.
-
Explain the difference between prefixing and post-fixing increment/decrement operators.
Postfix return the value before works on. Prefix return value affected by the operator.
-
What is operator precedence and how is it handled in JS?
Operator precedence determines the order in which operators are evaluated relative to each other. Operators with higher precedence become the operands of operators with lower precedence.
-
How do you log information to the console?
With console method log
-
What does unary plus operator do to string representations of integers?
It attempts to convert it into a number.
-
What are the eight data types in JavaScript?
Null, object, undefined, boolean, number, bigInt, string and symbol.
-
Which data type is NOT primitive?
Object.
-
What is the relationship between null and undefined?
They both are falsy and they are used by functions to return a no succesful response but they are different.
Undefined is a data type wich means there is not value assigned.
Null is a object type and it is a value assigned: null.
-
What is the difference between single, double, and backtick quotes for strings?
Single and double quotes are not functio0nally different. Backticks are used for template strings which allow to embed js code.
-
What is the term for embedding variables/expressions in a string?
Template literals (Template strings).
-
Which type of quote lets you embed variables/expressions in a string?
Backtick (`) characters.
-
How do you embed variables/expressions in a string?
Using brackets preceded by dollar symbol (${}). Ex: `string ${embedded_variable} string`
-
How do you escape characters in a string?
Using backslash (\) in front as an escape character.
-
What is the difference between the slice/substring/substr string methods?
The slice() method extracts a section of a string. When slice() receive negative values it counts backwards from the end of the string. if indexStart is greater than indexEnd, slice() method returns an empty string.
The substring() method returns the part of the string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.
The substr() method is considered a legacy feature in ECMAScript, so it is best to avoid using it if possible.
-
What are the three logical operators and what do they stand for?
And (&&), Or (||) and Not (!) operators. They are used to determine the logic between variables or values.
-
What are the comparison operators?
Comparison operators are used in logical statements to determine equality or difference between variables or values.
-
What are truthy and falsy values?
All values are truthy unless they are defined as false or 0, -0, 0n, "", null, undefined, and NaN.
-
What are the falsy values in JavaScript?
Those values whose evaluation return false.
-
What are conditionals?
Conditional statements allow us to represent such decision making in JavaScript.
-
What is the syntax for an if/else conditional?
if (statement) { // do something } else { // do something else } -
What is the syntax for a switch statement?
switch (expression) { case value1: //Statements to execute [break;] case value2: //Statements to execute [break;] ... case valueN: //Statements to execue [break;] [default: //Statements to execute [break;]] } -
What is the syntax for a ternary operator?
condition ? exprIfTrue : exprIfFalse -
What is nesting?
Nesting is when you write something inside of something else.
-
What are functions useful for?
A function is similar to a procedure —a set of statements that performs a task or calculates a value- but for a procedure to qualify as a function, it should take some input and return an output.
-
How do you invoke a function?
With () parenthesis and specified values as arguments.
-
What are anonymous functions?
It is a function that does not have any name associated with it.
-
What is function scope?
It is the function context and determines the accessibility of variables and other resources in the code, like functions and objects. JavaScript function scopes can have two different types, the locale and the global scope. Local variables are declared within a function and can only be accessed within the function.
-
What are return values?
A value from a function back to the code that called it by using the return statement. That value can be a constant value, a variable, or the result of the calculation is returned.
-
What are arrow functions?
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate limitations in usage.