JavaScript Flashcards
What is the default prototype of a function?
an object with the only property constructor
that points back to the function itself.
What is a prototype in JavaScript?
Prototypes are the mechanism by which JavaScript objects inherit features from one another
What is a class
in JavaScript?
Syntactic sugar for JavaScript’s existing prototype-based inheritance
What is the final link in any JavaScript Object’s prototypal chain?
technically, null
, but `Object’ sits at the top of any JavaScript Object’s prototypal chain.
What are JavaScripts 5 Primitive Data Types?
Number, String, Boolean, Undefined, Null
What is NaN in JavaScript?
Stands for ‘Not a Number’ - it is the result of any illegal numerical operations.
What are Falsy values in JavaScript?
0, “”, null, false, undefined, NaN
What is a Primitive Data Type?
Data that is not an object and cannot have methods.
What are the 5 different ways to declare variables or constants in JavaScript?
var, let, const, window, and global.
What is the difference between var, let and const?
[var] - is function scoped, meaning that it will be hoisted to the top of the function in which it is defined.
[let] - is block scoped. meaning that it will be only be hoisted to top of the block in which it is declared.
[const] - used to declare constants. They cannot be redeclared, but they can be reassigned.
What are the three different ways to declare a function in JavaScript?
1. Function-Style: function functionName(arg1, arg2, arg3, argN) { // code block... } 2. Expression-Style: const functionName = function (arg1, arg2, arg3, argN) { // code block... }; 3. Fat-Arrow Style: const functionName = (arg1, arg2, arg3, argN) => { // code block... };
What is a callback in JavaSrcipt?
A function that is passed to another function as an argument.
What is a closure in JavaScript?
an inner function that has access to the outer (enclosing) function’s variables—scope chain.
What is the difference between a pure and impure function?
A pure function is a function which given the same input, will always return the same value and it produces no side effects. An impure function is a function that mutates variables/state/data outside of it’s lexical scope.
What is the new
keyword?
The new keyword invokes a function in a special way. Functions invoked using the new keyword are called constructor functions.
- Creates a new object.
- Sets the object’s prototype to be the prototype of the constructor function.
- Executes the constructor function with this as the newly created object.
- Returns the created object. If the constructor returns an object, this object is returned.