Everything Flashcards

1
Q

What are the possible ways to create objects in JavaScript

A

object constructor (var object = new Object() and object literalt (var object = {})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is JSON?

A

JSON is a text-based data format following JavaScript object syntax. Used when you transfer data from back to front end. JSON.parse to convert string to object, and JSON.stringify to convert object to string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of the array slice method

A

The slice() method returns the selected elements in an array as a new array object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of the array splice method

A

The splice() method is used either adds/removes items to/from an array, and then returns the removed item. One difference is splice modifies the original array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between == and === operators

A

JavaScript provides both strict(===, !==) and type-converting(==, !=) equality comparison. The strict operators take type of variable in consideration, while non-strict operators make type correction/conversion based upon values of variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are arrow functions?

A

An arrow function is a shorter syntax for a function expression and does not have its own this, arguments, super, or new.target. These functions are best suited for non-method functions, and they cannot be used as constructors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a higher order function

A

Higher-order function is a function that accepts another function as an argument or returns a function as a return value or both.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is scope in javascript

A

Scope is the accessibility of variables, functions, and objects in some particular part of your code during runtime. In other words, scope determines the visibility of variables and other resources in areas of your code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Difference between foreach and map?

A

Both are iterators but map returns a new array whereas forEach won’t. ForEach is good when you want to check each element. Also map can be chained because it returns something.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

difference between var, let and const

A

var is function scoped meaning it’s only available where it is declared. It is also hoisted so it can be referenced before being initialized. var can be redeclared and updated. Let is block scoped meaning it’s only available within the curly brackets. Let can be updated but not redeclared. Let is hoisted to top but isn’t initialized. Const are similar to let in terms of being block scoped but where they differ is that they can’t be updated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is React?

A

React is a Javascript library created by Facebook. It’s component based and used to create single page applications. Single page applications only load the application code once. You stay on the same page and the Javascript changes/updates the html or DOM to display new things without speaking to the server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the features of React?

A

Some features of React are, component architecture, one way data flow, UI library, and Virtual Dom.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In calling setState, when would you pick one method of calling this function over the other?

A

You would use a function to set state when you need the current state or props of your component to calculate the next state. It is the most reliable to use the prevState function so you prevent the use of stale state or an “old” version of state that isn’t the current state. If you are certain you have the most current state or don’t need to the current state to calculate your setState then you can pass an object instead of a function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Is setState a synchronous or async call?

A

You can set state by directly passing in an object to set with, or create a function that will copy the current state and updates based on the changes you make to it in your function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

List some of the major advantages of React.

A

Reusable components, Virtual DOM, React Developer Tools, faster rendering.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the limitations of React?

A

React focus on the view part of MVC i.e. UI of the web application. So, to overcome these that to focus on other development we need other tooling set technologies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is JSX?

A

JSX is a syntax extention of Javascript. It produces react elements for the virtual DOM. It represents objects in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the virtual DOM? Explain how it works within ReactJS.

A

The Virtual DOM is a lightweight representation of the DOM. It exists in memory but is never rendered, In React JSX tells the template compiler how to build in the virtual DOM tree. The Render() function creates the virtual DOM tree. When your app is updated (from things like setState) there will be two virtual DOM trees in memory. React will compare the two trees and compare the differences then reconcile them create a patch then render them to the real DOM. That way all the updates are batched and the DOM is only ever updated once in each update.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Why can’t browsers read JSX?

A

Browsers don’t have inherent implementation for the browsers engine to understand JSX objects. Because JSX objects aren’t JavaScript objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Explain the purpose of render() in React.

A

Rendering is the React engine process walking through the virtual DOM and collecting the current state, props, structure, desired changes in the UI, etc.

The render function in react is used to create and update the UI. It describes how the ui should look on the browser window. It is part of the component life cycle and isn’t user called. It returns on JSX element that contains the view hierarchy for the current component. Render is called when: the react component is first instantiated following the constructor call, or after an update to the components props, or after a setState call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is Props?

A

Props are properties of components in react. They are used to pass data from parent component to child. Props are read only therefor should not be changed by the child component.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a state in React and how is it used?

A

State is a plain JavaScript object used by React to represent an information about the component’s current situation. The difference is while a “normal” variable “disappears” when their function exits, the state variables are preserved by React. It is used to enables a component to keep track of changing information in between renders and for it to be dynamic and interactive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How can you update the state of a component?

A

You update the state of a component by calling the setState function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is arrow function in React? How is it used?

A

When writing a class component, all of the functions that you write out will need to be bound to the constructor so that the ‘this’ keyword will behave in the appropriate manner to allow you properly render your data. With a standard function the definition of this is dependent on where the function is called, so you would normally need bind this to it in react to get the correct definition of this that we want. An arrow function doesn’t have it’s own definition of this so it inherits it from the constructor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Differentiate between stateful and stateless components. Stateful vs Stateless Components React

A

In react a stateful component holds a piece of state. By contrast a stateless component does not have state. A stateful component is keeping track of changing data while a stateless component prints out what is given to them via props or always rendering the same thing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What are the different phases of React component’s lifecycle?

A

There are three phases to a components life cycle: Mounting, Updating, and Unmounting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Why should we not update the state directly

A

If you try to update the state directly then it won’t re-render the component. Instead use setState() method. It schedules an update to a component’s state object. When state changes, the component responds by re-rendering.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is the difference between calling a promise and using a .then vs using await?

A

in .then() it runs through the entire function and then continues the execution before returning back to the .then when the promise is resolved. Whereas in await the function stops execution within the function scope until the promise is resolved

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is the Temporal Dead Zone

A

The Temporal Dead Zone is a behavior in JavaScript that occurs when declaring a variable with the let and const keywords, but not with var. In ECMAScript 6, accessing a let or const variable before its declaration (within its scope) causes a ReferenceError. The time span when that happens, between the creation of a variable’s binding and its declaration, is called the temporal dead zone.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is memoization

A

Memoization is a programming technique which attempts to increase a function’s performance by caching its previously computed results. Each time a memoized function is called, its parameters are used to index the cache.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What is undefined property

A

The undefined property indicates that a variable has not been assigned a value, or not declared at all. The type of undefined value is undefined too.

32
Q

What is null value

A

The value null represents the intentional absence of any object value. It is one of JavaScript’s primitive values. The type of null value is object. You can empty the variable by setting the value to null.

33
Q

What is the virtual DOM? Explain how it works within ReactJS.

A

The Virtual DOM is a lightweight representation of the DOM. It exists in memory but is never rendered, In React JSX tells the template compiler how to build in the virtual DOM tree. The Render() function creates the virtual DOM tree. When your app is updated (from things like setState) there will be two virtual DOM trees in memory. React will compare the two trees and compare the differences then reconcile them create a patch then render them to the real DOM. That way all the updates are batched and the DOM is only ever updated once in each update

34
Q

What is Model Binding (ASP.Net) and why is it important?

A

Model binding is asp.net is essentially the middle man between your incoming http request and your api controller. It is important because it binds the incoming http request with the proper controller action method.

35
Q

What are the fundamentals that a developer should consider when working to wire up model binding correctly?

A

Make sure your routing is correct to whatever the name of your specific service is. The correct interface is being provided in the constructor so that when the api controller is instantiated it has the correct methods that need the logic implemented for. Each service needs to have proper error handling so that errors do not get swallowed, meaning the error doesn’t come back in a response. Proper error handling includes multiple catches such as sqlexception, argumentexception, or exception. Have proper null checks in place so you can return an error that specifies if data isn’t passed in.

36
Q

What are the differences between an API Controller and a “regular/view” Controller in .Net?

A

API controllers are specialized in returning data. Json without serialization. Normal controllers are used to return views.

37
Q

Describe the main differences or considerations between the JS and C#.

A

C# is a static typed language meaning it’s type checking at compile and can’t run without you fixing them. JavaScript is dynamically typed so you can attempt to run it even if you have errors. C# also requires you to define the data type of your variables whereas JavaScript doesn’t.

38
Q

What is an MVC View?

A

Model-View-Controller View is a display using the model class object. It is a software class and contains a template and data form to produce a response for the browser.

39
Q

What is a Model?

A

A model represents the shape of data as public properties and business logic as methods. Think of like your USERS or ADDUSERREQUEST.

40
Q

What are Interfaces?

A

Interfaces are contracts that defines methods or properties that an implementing class must provide implementing logic for.

41
Q

What is an abstract class and is this different than an interface?

A

An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to define functionality, not implement it. And whereas a class can extend only one abstract class, it can take advantage of multiple interfaces.

42
Q

Can you create an instance of an abstract class?

A

No you cannot because it does not have a complete implementation. The purpose of an abstract class is to function as a base for subclasses. it acts like a template or an empty structure you should extend and build on it before use.

43
Q

What are the principles of object-oriented programming?

A

Encapsulation - Restricting access to methods and attributes of certain classes (private). Preventing accidental modification of data or unwanted changes.

Abstraction - extension of encapsulation, process of selecting data from a larger pool to show only the relevant details to the object. (Only certain data needed to create account on dating app, things such as favorite food or hobbies isn’t needed)

Inheritance - the ability for one object to acquire some/all properties of another object. Such as updateUser : addUser

Polymorphism - A way to use a class exactly like its parent so there is no confusion with mixing types. Example Testdata has methind add(int a, int b, inc ) returns a + b + C. Another class can take a new version named t = new testdata() then get the method and bring in it’s own parameters. t.add(3 + 5 + 8) returns = 16.

44
Q

What does it mean to be a strongly typed language?

A

Static typing is where the type is bound to the variable. Types are checked at compile time.

Dynamic typing is where the type is bound to the value. Types are checked at run time.

A strongly-typed programming language is one in which each type of data (such as integer, character, hexadecimal, packed decimal, and so forth) is predefined as part of the programming language and all constants or variables defined for a given program must be described with one of the data types.

45
Q

What is a static member or property in .Net?

A

Astaticclass is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. In other words, you cannot use thenewoperator to create a variable of the class type. Because there is no instance variable, you access the members of a static class by using the class name itself. For example, if you have a static class that is named UtilityClass that has a public static method named MethodA, you call the method as shown in the following example: UtilityClass.MethodA();

46
Q

What are the different types of HTTP methods? When would you use these over others?

A

GET - requests data

POST - SUBMIT to a specified resource

PUT - UPDATE data on a target resource

DELETE - DELETES specified resources

47
Q

What is a Database?

A

A SQL database is a collection of tables that stores a specific set of structured data.

48
Q

What is a relational Database?

A

A relational database organizes data into tables which can be linked—orrelated—based on data common to each. This capability enables you to retrieve an entirely new table from data in one or more tables with a single query.

49
Q

What is a database “Table”?

A

A table is a collection of related data held in a table format within a database. It consists of columns and rows.

50
Q

What is a Primary Key and how many can one table have?

A

Primary key is a column or set of columns that uniquely identity a row in a table. A table can have one primary key. A primary key constraint can be on multiple columns though.

51
Q

What is a Foreign Key and how many can one table have?

A

A Foreign Key is a field(columns) (or collection of fields(columns)) in one table that refers to the primary key in another table. The table with the foreign key is called the child table, and the table with the primary key is called the referenced or parent table.

A table can have as many foreign keys as you want up to 253.

52
Q

What is a SQL Injection Attack and how do you protect yourself against these?

A

SQL injection attacks are when someone finds and exploits unsanitized inputs. They use the warning window provided to see if they can get information, sometimes companies pass too much information. Three ways to protect from injection attacks: Web Application Firewalls - analyze and separate malicious HTTP and HTTPS request heading to your website. Parameterized Queries - Parameterized queries will segregate the data added by an user from the code that runs the application so the two don’t interact with each other. Reduce account privileges so that unauthorized accounts can’t get admin privileges.

53
Q

What is a Sql Server stored procedure?

A

A SQL stored procedure (SP) is a collection SQL statements and sql command logic, which is compiled and stored on the database. Stored procedures in SQL allows us to create queries to be stored and executed on the server. Stored procs can also be cached and reused.

54
Q

What language is used to write Stored procedures?

A

Transact SQL or T/SQL for short

55
Q

What are the different types of statements available to you in TSQL?

A

Data Definition Language - Create, Alter, Drop, Truncate etc…

Data Manipulation Language - Insert, Delete, Bulk Insert, Select, Update, merge etc….

56
Q

What are indexes?

A

Sql index is a quick lookup table for finding records users need to search frequently. When you create a primary key a clustered index is automatically created with it. Same as when you put a unique constraint on a column.

57
Q

What are the basic parts of a simple TSQL Query

A

Input/Select, Execution, Output

58
Q

When are “Joins” used?

A

Joins are used to return data that is related in a relational database. Data can be related in 3 ways: one to one (student only as one id), one to many(a customer can have many orders), and many to many (dr can have many patients and patients can have many dr.)

59
Q

What are the different types of Joins? (Write examples of each)

A

Inner Join - will return data form both tables where the keys in each table match

Left or Right Join - will return all the rows from one table and matching data from the other table.

Cross Join - will return the product of each table.

60
Q

What is data normalization?

A

Data normalization rules divides large tables into smaller tables and links them using relationships.

61
Q

Why would we go through the process of normalizing our data?

A

To prevent oversized data tables, data inconsistency. Input update or delete statements will become frequent anomalies. Meaning they will have to apply to every row that is a duplicate of the targeted row.

62
Q

What is the difference between public, static, and void

A

Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class.

Static member are by default not globally accessible it depends upon the type of access modified used.

And Void is a type modifier that states that the method or variable does not return any value.

63
Q

What is serialization

A

When we want to transport an object through a network, then we have to convert the object into a stream of bytes. The process of converting an object into a stream of bytes is called Serialization.

64
Q

What are HTTP status codes

A

200 - OK

301 - Permanent Redirect

404 - Not Found

500 - Internal Server Error

503 - Service Unavailable

65
Q

What is the difference between React context and React Redux

A

You can use Context in your application directly and is going to be great for passing down data to deeply nested components which what it was designed for.

Whereas Redux is much more powerful and provides a large number of features that the Context API doesn’t provide. Also, React Redux uses context internally but it doesn’t expose this fact in the public API.

66
Q

Explain the lifecycle methods of React components in detail.

A

In the MOUNTING phase there are 4 methods.

Constructor(): called before anything else, when the component is initiated, and it is the natural place to set up the initial state and other initial values.
method is called with the props, as arguments, and you should always start by calling the super(props) before anything else, this will initiate the parent’s constructor method and allows the component to inherit methods from its parent (React.Component).
GetDerivedStateFromProps(): method is called right before rendering the element(s) in the DOM. Tts where you would set the state object based on the initial props.
render()- method is required, and is the method that actually outputs the HTML to the DOM.

ComponentDidMount()- called after the component is rendered. A natural place to do your api calls.

in the UPDATING(whenever there is a change to a components state or props) phase there are five methods

GetDerivedStateFromProps() - first method called when a component gets updated. Same as the mounting phase its a good place to set the state object based on initial props.

shouldComponentUpdate()- returns a boolean value that specifies whether react should continue with rendering or not. Default is true.

render()- method is required, in the update phase it will re-render the HTML to the DOM with new changes.

getSnapShotBeforeUpdate()- in this method you have access to props and state before the update. So after the update you can check the previous props and state. You should include componentDidUpdate() method otherwise you will get an error.

componentDidUpdate() - called after the component is updated in the DOM.

UNMOUNTING phase as one method

componentWillUnmount() - called when the component is about to be removed from the DOM.

67
Q

What is the significance of keys in React?

A

Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity When children have keys,React uses the key to match children in the old tree with children in the new tree.

68
Q

What is React Router?

A

React Router is a standard library for routing in React. It enables the navigation among views of various components in a React Application, allows changing the browser URL, and keeps the UI in sync with the url.

69
Q

Why is Switch component used in React Router v4?

A

A switch component is used when we want to render a route exclusively to the specified route. Switch will render the first child of route or redirect that matches the location.

70
Q

Why do we need a Router in React?

A

We need router in react so we can navigate among components, allow changing the browser url, and keeping the ui synced with the url. For a user it allows them to navigate through our application without having to refresh on every page change.

71
Q

How is React Router different from conventional routing?

A

In conventional routing each page has a file that corresponds to it, and if the url changes then a request is sent to a server and the corresponding html is sent back. With react router no server is involved it’s all client side. Only one html page is involved, and only the history attribute is changed when the url is changed.

72
Q

What are hooks

A

Hooks is a new feature(React 16.8) that lets you use state and other React features without writing a class.

73
Q

Hooks you know of and have used?

A

useState, useEffect, useDispatch, useContext, useReducer, useMemo

74
Q

Explain CSS position property

A

Absolute: To place an element exactly where you want to place it. absolute position is actually set relative to the element’s parent. if no parent is available then the relative place to the page itself (it will default all the way back up to the element).

Relative: “Relative to itself”. Setting position: relative; on an element and no other positioning attributes, it will no effect on its positioning. It allows the use of z-index on the element and it limits the scope of absolutely positioned child elements. Any child element will be absolutely positioned within that block.

Fixed: The element is positioned relative to the viewport or the browser window itself. viewport doesn’t change if you scroll and hence the fixed element will stay right in the same position.

Static: Static default for every single page element. The only reason you would ever set an element to position: static is to forcefully remove some positioning that got applied to an element outside of your control.
Sticky: Sticky positioning is a hybrid of relative and fixed positioning. The element is treated as relative positioned until it crosses a specified threshold, at which point it is treated as fixed positioned.

75
Q

What are the different ways to hide the element using CSS?

A

Using display property(display: none). It’s not available for screen readers. The element will not exist in the DOM if display: none is used.

Using visibility property(visibility: hidden), will take up the space of the element. It will be available to screen reader users. The element will actually be present in the DOM, but not shown on the screen.

Using position property (position: absolute). Make it available outside the screen

76
Q

Difference between CSS grid vs flexbox

A

CSS Grid Layout is a two-dimensional system, meaning it can handle both columns and rows. Grid layout is intended for larger-scale layouts which aren’t linear in design.

Flexbox is largely a one-dimensional system (either in a column or a row). Flexbox layout is most appropriate to the components of an application.