Technical Questions Flashcards
What are some core principles of functional programming?
Immutability, purity, first class functions, and high order functions.
Please elaborate
What makes a function pure?
A function that always returns the same result if the same arguments are passed.
What is immutability?
Idea that once an object or variable has been created, its values should never change or be updated by anything.
What is a higher order function?
It is a function that accepts functions as parameters and/or returns a function.
What is the purpose of a return statement in a function?
A return statement ends the execution of a function, and returns control to the calling function; a return statement can return a value to the calling function.
What is function composition?
Powerful technique used in programming to combine multiple functions into a single, more complex function. More efficient and reusable code.
What is currying?
Currying transforms a function with multiple arguments into a nested series of functions, each taking a single argument.
What are some of the advantages of functional programming?
Enhanced code readability and maintainability. Better scalability and performance optimization. Reduced complexity and improved debugging.
What is a closure, and how/why would you use one?
A closure is the combination of a function bundled together with references to its surrounding state (lexical environment); a closer gives you access to an outer function’s scope from an inner function.
Explain the concept of hoisting.
Default behavior to moving all the declarations at the top of the scope before code execution. No matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local.
What is the ‘This’ keyword in JavaScript?
‘This’ keyword refers to an Object is executing the current piece of code. References the Object that is executing the current function.
Explain the concept of event delegation?
A pattern that efficiently handles events. Events can be added to a parent element instead of adding to every single element. Refers to the process of using event propagation (bubbling) to handle events at a higher level in the DOM than the element on which the event originated.
What is a Promise and why is it helpful?
Used to handle asynchronous operations in JavaScript. Perform operations inside the callback function and if everything went well then call resolved. If desired operations do not go well call rejected.
What is block scope and how is it different from global and local scope?
Block scope: Variable that is declared inside a specific block and cannot be accessed outside of that block. Block scopes are what you get when you use ‘if statements’, ‘for statements’ etc.
Why is it in general, a good idea to leave the global scope of a website as-is and never touch it?
JavaScript that is executed in the browser has access to the global scope, and if everyone uses the global namespace to define their variables, collisions will occur.
What is the difference between ‘null’ and ‘undefined’?
Undefined means the variable has been declared, but it’s value has not been assigned. Null means an empty value or blank value.
What’s the difference between ‘let’ and ‘const’?
Var variables can be updated and re-declared within its scope. Let variables can be updated but not re-declared. Const variables can neither be updated nor re-declared. Const = constant.
What is an event loop?
An event loop is something that pulls stuff out of the queue and places it onto the function execution stack whenever the function stack becomes empty.
What does event bubbling or propagation mean?
Event bubbling is a method of event propagation in HTML, DOM when an event is in an element inside another element. And both elements have registered a handle to that event. It’s a process that starts with the element that triggered the event and then bubbles up to the containing elements in that hierarchy.
What is “use strict”? What are the advantages and disadvantages to using it?
“Use strict” tells the browser to use Strict mode, which is reduced and safer feature set of JavaScript. Strict mode makes several changes to normal JavaScript semantics. It eliminates some JavaScript silent errors by changing them to throw errors.
How is an array different from an object?
Arrays are best to use when the elements are numbers, want to create and store a list of multiple items in a single variable. Ordered collections or lists can be accessed using an index starting at zero.
Objects are best to use when the elements are strings. Mutable and used as a collection of data to represent key-value pairs. Both can add or remove items and both are complex data structures.
How do you interact with APIs on the front end? What is an API?
Make HTTP requests to remote servers to fetch or send data. Invokes asynchronous JavaScript so need to ensure that code properly handles the timing of API responses using Promises, async/await, callback functions.
What is chaining in JavaScript?
Method Chaining allows us to run multiple methods on the same element within a single statement.
Define the term ‘MVC’ and explain how an application is architected when following MVC patterns.
Model-View-Controller (MVC) framework is an architectural/design patterns that separates an application into three main logical components- Model, View, and Controller. Architectural pattern consists of three parts: Model, View, Controller.
Model handles the data logic.
View displays the information from the model to the user.
Controller controls the data flow into a model object and updates the view whenever data changes.
What does CORS stand for and what issue does it address?
Cross Origin Resource Sharing. HTTP-header based mechanism which enables the server to allow or restrict access from any other origins.
What does npm build do?
Npm build creates a build directory with a production build of your app.
What can you tell me about RESTful APIs?
RESTful API is an interface that two computer systems use to exchange information securely over the internet. Uses HTTP requests to access and use data. GET, PUT, POST, DELETE data types.
Representational State Transfer or REST
What is JSON and how does it work?
JavaScript Object Notation is a lightweight format for storing and transporting data (sending data from the server to the client)
JSON is a format for communicating and storing data
A collection or object consisting of key value pairs as strings.
Can also send JSON to the server using JSON.stringify()
Can also take JSON string as input and construct the value/object (work with JSON as an object)
JSON.parse()
What is the difference between ES5 and ES6?
In ES5 there is one way of defining variables using a ‘var’ keyword. In ES6 you are introduced to two more ways of defining variables with let and const. Also introduced to the arrow function which eliminates need for keyword ‘function’. Introduced to Promise() which is a convenient way of handling callbacks. Import and export modules available. String interpolation with template literal or backtick.
What’s the difference between an HTTP request and response?
Requests are sent by the client to trigger an action on the server. Responses return an answer from the server.
In HTTP “request/response” system, the “requesting” computer or “client” asks another computer for information. The “server” sends back a “response” with the information requested.
What does a 200 status code mean?
OK status code means the request was successful.
What does a 400 status code mean?
Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client side error.