JavaScript Flashcards
What is prototypical inheritance and why is it useful?
The idea that every object in JS has a prototype from which it inherits values and behaviours. If an object doesn’t include a property that’s being requested, JS will look for it inside its prototype. Prototypical inheritance is useful when making objects that share the same values and operations, so that only one copy of the prototype object exists.
What is event capturing and event bubbling?
In event capturing, the parent element will capture the event first and then propagate it to the child elements. In event bubbling, the child element will capture the event first and then propagate it to parent elements.
What does the term ‘hoisting’ mean?
Hoisting is JavaScripts default behaviour of moving all function and variable declaration to the top of the current scope before code execution.
What is the difference between const, let, and var?
A const variable cannot be redeclared or updated. A let variable can be updated but cannot be redeclared (unless within a different scope). A var variable can be redeclared and updated.
What is the difference between const, let, and var?
A const variable cannot be redeclared or updated. A let variable can be updated but cannot be redeclared (unless within a different scope). Both let and const have block scope. A var variable can be redeclared and updated, and has global/function scope.
What is a pure function?
Pure functions are functions that are not affected by any data outside the scope of that function. Pure function return the same values given the same parameters/arguments.
What is functional programming?
Functional programming focuses on creating programs by passing application state exclusively through functions. This means all work but be done inside pure functions, and any state within an application should be passed as a parameter to a function.
What is an asynchronous function?
An asynchronous function is a function which operates asynchronously via the event loop and using and uses an implicit Promise to return the result. In an AF an await keyword is used to the pause the execution of the async function and wait for the passed promise’s resolution before resuming the remainder of the function.
What is “strict mode” and how can we apply it to our code?
Strict Mode prompts JavaScript to display all errors and warnings, even if they are silent. To enable Strict Mode, add “use strict” to the beginning of the script.
What is “strict mode” and how can we apply it to our code?
Strict Mode prompts JavaScript to display all errors and warnings, even if they are silent. To enable Strict Mode, add “use strict” to the beginning of the script, program or function.
What is the difference between “null” and “undefined”
Null is returned when you are accessing a variable that has been assigned the value of null, whilst undefined is returned when accessing a variable that has not been assigned a value.
What is the difference between function declaration and function expression?
Function declaration is the normal process of defining a function using the keyword function. However, once you assign a function declaration to a variable then it becomes a function expression.
What are three common JavaScript frameworks and what are they used for.
React, Vue and Angular are commonly used frameworks and are used to build web interfaces.