Full-Stack Basics Flashcards

Learn key React concepts

1
Q

What is Model Binding?

A

Model binding retrieves data from requests, populates controller action parameters, takes care of property mapping and type casting typically involved in working with ASP.Net request data.

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

What is a Database?

A

A database is an organized collection of structured information, or data, stored in a computer system. It’s set up to easily store, query, and manage data. Commonly stored in tables.

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

What is a relational Database?

A

A relational database is a type of database that stores and provides access to data points that are related to one another. These databases are based on relation model, an intuitive, straightforward way of representing data in table.

In a relational database, each row in the table is a record with a unique ID called the key. The columns of the table hold attributes of the data, and each record usually has a value for each attribute, making it easy to establish the relationships among data points.

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

What is a primary key and how many can on table have?

A

Primary keys are a columns or a group of columns to uniquely identify and index each record within a table.

A table is only allowed one Primary Key

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

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

A

Foreign keys are a column or a group of columns in a database that are linked to a column in a different table.

This existence of a foreign key column establishes a foreign key constraint.

A table can have multiple foreign keys excluding the primary key column.

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

What are Indexes?

A

An index is a data structure that provides a quick lookup mechanism for finding rows in a table based on the values of one or more columns.

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

If you wanted to delete information from a table what statement would you use?

A

The delete statement Removes one or more rows from a table or view.

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

What is the truncate statement used for? What is the key difference between this and your other options to remove data?

A

the truncate statement removes all rows from a table or specified partitions of a table, without logging the individual row deletions. The delete statement logs each individual row deletion in the transaction logs.

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

What is data normalization

A

Database normalization, is technique to organize the contents of the tables for transactional databases and data warehouses to avoid redundancy.

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

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

A

There are four goals of data normalization.

  1. arranging data into logical groupings so that each group describes a small part of the whole.
  2. minimizing the amount of redundant data in a database.
  3. organizing the data so that when you modify it, you make the change in only one place.
  4. building a database in which you can access and manipulate the data quickly and efficiently without compromising the integrity of the storage.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you declare a variable in TSQL?

A

DECLARE { @LOCAL_VARIABLE data_type [ = value ] }

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

How many normal forms are there?

A

There are 6 normal forms

the primary forms are:
1NF - Each record entry must contain only a singular value.
2NF - The data must have only one primary key. Then, relationships can be created through new foreign key labels.
3NF - The data in a table must only be dependent on the primary key. If the primary key changes all impacted data must be put into a new table.

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

What is a SQL Server?

A

SQL Server: SQL Server is a relational database management system (RDBMS) created by Microsoft. This software allows the user to store and manage data in a structured format, enabling users to interact with the data using the SQL or Structured Query Language, programming language.

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

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

A

SQL injection is one of the common web attack mechanisms used to steal sensitive data from organizations. It is a code injection technique that hackers use to insert malicious SQL statements into input fields on an application for execution by the underlying database

Protect against these attacks using stored procedures and parameters.

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

If a stored procedure is too slow how can you enhance the speed?

A

You can review the execution plan to ensure that ‘table scans’ are minimized and ‘index scans’ are used, instead.

If more information is required you can use SQL Server Profiler to collect information about queries being executed and have SQL Server provide optimization recommendations.

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

What are higher order components?

A

A higher Order Component is an advanced way of reusing the component logic. HOC are custom components which wrap other components but they wont modify or copy and behavior from their input component.

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

What are the limitations of React?

A
  1. React is a library not a framework
  2. Its a very large library and take time to grasp
  3. It can be difficult to understand
  4. Coding gets complex as it uses inline templating and JSX
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a SQL Server stored procedure?

A

A SQL Server stored procedures are a reusable set of SQL commands that you can save and call whenever you need them.

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

What language is used to write Stored procedures?

A

Stored procedures in SQL Server are written using Transact-SQL (T-SQL).

It’s an extension of SQL (Structured Query Language) specifically designed for programming stored procedures, functions, and other database objects.

T-SQL includes additional programming constructs such as variables, control-of-flow statements, and error handling, allowing you to create more complex and powerful database routines.

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

What language do you use to communicate with the database?

A

To communicate with a database use a language called SQL (Structured Query Language). SQL is specifically designed for managing and manipulating data stored in relational database management systems (RDBMS). It allows you to perform various operations such as querying data, inserting, update, and deleting records.

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

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

A
  1. Data Manipulation Language (DML) Statements - These statements are used to manipulate data stored in the database.
  2. Data Definition Language (DDL) Statements - These statements are used to define, modify, and delete database objects such as tables, views, indexes, and stored procedures.
  3. Data Control Language (DCL) Statements - These statements are used to control access to the database objects.
  4. Transaction Control Statements - These statements are used to control transactions in the database.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are the basic parts of a simple TSQL Query?

A
  1. SELECT Clause: Specifies the columns or expressions to be retrieved from the database.
  2. FROM Clause: Specifies the table or tables from which to retrieve the data. It defines the source of the data for the query.
  3. WHERE Clause (Optional): Filters the rows returned by the query based on specified conditions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are “Joins” used for?

A

Joins are used when you want to combine data from two or more tables into a single result set based on a related column or condition.

This allows you to retrieve and display information that is spread across multiple tables in the database.

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

What is an Inner Join?

A

An inner join is a type of join in SQL that returns only the rows from both tables that satisfy the join condition.

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

What is a Full Join?

A

A full join, also known as a full outer join, is a type of join in SQL that returns all rows from both tables being joined, regardless of whether there is a match between the tables.

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

What is a Left Join?

A

A left join, also known as a left outer join, is a type of join in SQL that returns all rows from the left table (the “left” side of the join), along with matching rows from the right table (the “right” side of the join). If there is no match for a row in the right table, the columns from the right table will contain NULL values in the result set.

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

What is a Right Join?

A

A right join, also known as a right outer join, is a type of join in SQL that returns all rows from the right table (the “right” side of the join), along with matching rows from the left table (the “left” side of the join). If there is no match for a row in the left table, the columns from the left table will contain NULL values in the result set.

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

What does it mean to be a strongly typed language?

A

A strongly typed language is a programming language where every variable must be associated with a specific data type, this data type is enforced at compile-time. Once a variable is declared with a certain data type, it cannot be used to store values of any other incompatible data type without explicit conversion.

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

In .Net how many classes can one class inherit from?

A

In .NET, a class can inherit from only one base class. This is known as single inheritance. Unlike some other programming languages like C++, which support multiple inheritance

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

What are Generics in .Net?

A

Generics in .NET provide a way to define classes, interfaces, and methods with placeholders for the data types they operate on.

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

Why are Generics so important?

A

This allows you to create flexible components and algorithms that are type-safe and reusable across different data types which also leads to less redundant code.

-DRY Principle.

  • Generics are widely used in defining collection classes. These generic collection classes provide type-safe storage for elements of any data type, making it easy to work with collections of objects.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is IEnumerable and what significance does it hold?

A

IEnumerable in .NET represents a list of items that can be enumerated or that you can go through one by one. It’s like a book with pages you can turn, where each page is an item in the list. This interface is important because it allows you to work with collections of objects in a flexible and efficient way. It’s commonly used for tasks like looping through items, filtering data, and performing calculations.

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

Can you create an instance of an abstract class?

A

No.

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

What are Interfaces?

A
  • An interface defines a contract for classes by specifying a set of method and property signatures that implementing classes must provide.
    • Interfaces cannot contain any implementation code; they only define method and property signatures.
    • A class can implement multiple interfaces, allowing it to adhere to multiple contracts.
    • Interfaces are useful for achieving polymorphism and creating loosely coupled systems, as they enable classes to interact with each other without knowing the specific implementation details.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What are Nullable Types?

A

Nullable value types allow variables to have an additional state beyond their normal range of values. they extend this behavior by allowing variables to have the value of null in addition to their usual range of values. Null the absence of value

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

What are the different parts of a Connection String?

A

The Database/server name your trying to access, User credentials, and Password

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

What are Connection Strings?

A

Connection strings are strings of text used to specify information needed to connect to a database or another data source.

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

How do you access the underlying value of a Nullable Type?

A

There are two ways to access the underlying the value of a nullable type using either the “.Value” property if you know the nullable type has a value.

int? nullableInt = 10;
int intValue = nullableInt.Value ;

If you are unsure you can access the underlying value using the Null-Coalescing Operator “??”. You can use this by placing the nullable type on the left of the “??” and the value to give it, if it is null.

int? nullableInt = 10;
int intValue = nullableInt ?? 0 ;

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

What is the best way to concatenate strings in .Net and why?

A

The best way to concatenate strings is to use the “StringBuilder” class. The reason is because it is optimized to be efficient, use less memory, readability, and mutability(allowing you to modify the string buffer directly.

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

What are Collections in .Net?

A

Collections are objects that store groups of related elements. some examples: lists, arrays, dictionaries, and sets

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

How would you declare an array in C#?

A

typeName[] arrayName = { value1, value2, …, valueN };

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

What is attribute routing?

A

Allows developers to define routes directly within their controller classes and action methods using attributes. This means you can specify URLs for your web API endpoints right where you define your methods.

Attribute routing provides a more concise and intuitive way to define routes, making it easier to understand and maintain your API’s URL structure.

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

How do you store Flags in an Enum?

A

Storing flags in an enum involves using the [Flags] attribute in C#. This attribute allows you to combine enum values using bitwise operations to represent multiple flags.

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

What is a static member or property in .Net?

A

A static property in .NET is a class-level member that belongs to the type itself. It is shared among all instances of the class and can be accessed directly through the class name. No instance necessary

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

What is a Model?

A

A model is a C# class that is responsible for handling data and logic. It represents the shape of the data and is responsible for handling database related changes.

44
Q

What is an MVC View?

A

A “regular” or “view” controller refers to a controller that is primarily responsible for handling HTTP requests and generating HTML views to be displayed in a web browser.

45
Q

What is a Null Reference Exception?

A

A Null Reference Exception is a runtime error that occurs when you try to access or manipulate an object or variable that has a null value.

46
Q

What are C# extension methods?

A

Extension methods enable you to “add” methods to existing types without modifying the original type.

47
Q

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

A

An abstract class is a class that cannot be instantiated directly and serves as a blueprint for other classes to inherit from.

while both interfaces and abstract class cant be instantiated and must inherited. I class can only inherit one abstract class and abstract class can hold default logic can provide access modifiers.

48
Q

What do you use to debug C#?

A

Visual Studio Built in Debug which you can use by pressing F5 or the debug option in your toolbar

49
Q

What is React?

A

React is a JavaScript library used for building user interfaces (UIs) in web applications. It allows developers to create interactive and dynamic UI components that can efficiently update in response to user actions or changes in data.

50
Q

What is JSX?

A

JavaScript XML or JSX is a unofficial JavaScript Syntax used by react.

51
Q

What are Pure Components?

A

Pure Components are components that automatically optimize performance by comparing their props and state between renders. If the props and state remain the same, the component prevents unnecessary re-renders, leading to improved performance.

52
Q

What are the features of React?

A

1.Component-Based
2. Virtual DOM
3. Declarative Syntax - developers describe what the UI should look like based on current state, if state change UI changes
4. One-Way Data Flow
5.JSX
6. React Hooks - functions that allow components to use state and other features without needing to create a class.
7. Component Lifecycle

53
Q

What is NPM/Yarn?

A

NPM and Yarn are two of the most popular package managers among JavaScript and Node. js developers.

A package is a namespace that organizes a set of related classes and interfaces.

54
Q

What is React.memo ?

A

React. memo memoizes a functional component and its props. Doing so helps prevent unnecessary re-renderings

55
Q

What is Props?

A

A mechanism for passing data from a parent component to a child component.

56
Q

Why can’t browsers read JSX?

A

Since JSX is a unofficial JavaScript Syntax browsers can not read it therefore it must be trans-compiled down into a version of JS that the browsers can read.

57
Q

What is an event in React?

A

An event is an action that could be triggered as a result of the user action or system generated event

58
Q

What are synthetic events in React?

A

a cross-browser wrapper around the browser’s native event. It combines the behavior of supported events of different browsers into one API, ensuring that events work identically across all browsers.

59
Q

What can you do with HOC?

A

They allow you to reuse component logic across multiple components.

ex.
1. Prop Manipulation - HOCs can manipulate props passed to wrapped components, such as adding new props, modifying existing props, or providing default prop values.
2. State Management - HOCs can manage state and lifecycle methods for components, allowing you to abstract away state management logic and provide it as a reusable higher-order component

60
Q

What is the significance of keys in React?

A

Keys are special attributes used to uniquely identify components with in a list. they are significant in React because they aid in determining whether items in a list have been changed, updated, or removed.

61
Q

What is React Router?

A

React Router is a popular routing library for React applications that enables navigation and URL routing within single-page applications (SPAs).

62
Q

Why do we need a Router in React?

A

In React, a Router is needed to manage the navigation and URL routing within a single-page application (SPA).
1. enables SPA applications
2. handles client-Side Navigation
3. defines routes for different URL Patterns an maps them to specific components
4.Supports nested routs
5. enable bookmarking and history management

63
Q

What is a ref in React?

A

A ref is a special attribute that allows you to reference a DOM element or a class component instance created by a React component. Refs provide a way to access and interact with DOM elements or React components directly, without having to rely on state or props.

64
Q

List some of the cases when you should use Refs.?

A

focus an input field, creating a component to persist through re-renders, or fetch an input.

65
Q

How do you modularize code in React?

A

Modularizing code in React involves organizing your application’s components, styles, and functionality into smaller, reusable modules. This helps improve code maintainability, readability, and scalability

66
Q

How do you create an event handler in React?

A

Create a funcation and then attach that function to an event, attributes such as onClick, onChange, or onSubmit.

67
Q

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

A

Mounting Phase, Updating Phase, Unmounting Phase

68
Q

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

A

In React, state is an object that represents the internal data of a component. It allows components to keep track of their own data and manage changes to that data over time.

69
Q

How can you update the state of a component?

A

In React, you can update the state of a component using the setState() method provided by the Component class or the useState() hook if you’re using functional components with hooks.

70
Q

What is the generic name of the library used in .Net that is used to communicate with Databases?

A

ADO.NET

71
Q

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

A

JavaScript is a prototype-based language, it is dynamic and weakly typed, JS is a scripting language, JS can have syntax errors that occur at runtime.

C#, is a class based object-oriented language, its is statically and strongly typed, C# is a compiled language, it will not run it finds an error as it is compiling

72
Q

What are the principles of object-oriented programming?

A
  1. encapsulation - classed
  2. abstraction - Interfaces and abstract classes
  3. inheritance
  4. polymorphism - overloading and overriding
73
Q

What is Authorization? At what level does it typically happen your application?

A

Authorization is the process of determining whether a user has permission to access certain resources or perform specific actions within an application. It typically happens at the level of the application’s backend or server-side code.

74
Q

Is setState a synchronous or async call?

A

async call, because setState is batched so that all the setState calls of a component can be executed together for speed and efficiency

75
Q

Explain the purpose of render() in React.

A

When React renders a component, it calls the render() method to generate the UI elements that will be displayed on the screen.

76
Q

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

A

The fundamentals are accurate spelling, data types, and validation. If the data types don’t match with what the method requires, then the method could error or not even start.

77
Q

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

A

A regular controller takes a HTTP request and brings data that will be rendered as a view, what you see on the screen. An API Controller is more concerned with routing and getting a response back from the API.

78
Q

When creating a new controller, what class do you inherit from?

A

When creating a new controller in .NET, you typically inherit from the Controller class if you’re building a regular/view controller, or from the ApiController class if you’re building an API controller.

79
Q

What are the .Net objects and classes used to communicate and execute commands at the database?

A

ExecuteNonQuery()
ExecuteCmd()
SqlCommand
SqlConnection
SqlDataReader
SqlDataAdapter
DataSet
SqlTransaction

80
Q

How can you test if an instance of an object implements a particular interface?

A

In .NET, you can test if an instance of an object implements a particular interface using the is keyword or the as keyword.

81
Q

What does your typical error handling code look like?

A

Try/catch blocks

82
Q

What is the Web.Config/ApplicationSettings.json? What do you use it for?

A

The appsettings. json file is generally used to store the application configuration settings such as database connection strings, any application scope global variables, and much other information.

83
Q

How does one implement authorization? (Make sure only known users are allowed to execute code)

A

To ensure only known users can execute code in .NET:

-Authentication: Verify user identity through credentials.
-Authorization: Define what actions users are allowed to perform.
-Role-based Authorization: Assign roles to users and restrict access based on roles.
-Policy-based Authorization: Define custom policies to control access.
-Claims-based Authorization: Use assertions (claims) about users for access control.
-Custom Authorization: Implement specialized logic as needed.

84
Q

How does the webserver know who you are across different web requests?

A

The server also generates a session ID and transmits it to the user’s browser. The identifier is usually stored as a cookie on that browser.

85
Q

What are the first 4 numeric values of an Enum used to store Flags?

A

0, 1, 2, 4 doubling after that

86
Q

How do you send email on the server?

A

-Choose Method: Decide whether to use an SMTP server or an email-sending library.
-Configure Settings: Set up email server details or configure the library with sender and recipient information.
-Write Code: Implement logic to send emails programmatically.
-Handle Errors: Manage any errors that may occur during email sending.
-Test: Thoroughly test the email sending functionality before deploying.
-Monitor: Keep an eye on email delivery and address any issues promptly.

87
Q

In an API application, what information is used to route your request?

A

-HTTP Method: Specifies the action to be performed (e.g., GET, POST, PUT, DELETE).
-URI (Uniform Resource Identifier): Specifies the endpoint or resource being accessed (e.g., /users, /products/123).
-Headers: Contains additional metadata about the request (e.g., content type, authentication tokens).
-Query Parameters: Additional data appended to the URI for filtering or pagination purposes (e.g., ?page=1&limit=10).
-Request Body: Data sent with the request, usually in the form of JSON or XML, for operations like creating or updating resources.

88
Q

What routing protocol is normally used in a web request?

A

In a web request, the HTTP (Hypertext Transfer Protocol) protocol is typically used for routing.

89
Q

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

A

HTTPGET
HTTPPOST
HTTPPUT
HTTPDELETE

90
Q

What is the difference between a string and a string builder and when would you use one over the other?

A

Performance: StringBuilder is faster when performing several concatenations, as it doesn’t create a new object each time. Thread Safety: String is thread-safe because it’s immutable. Multiple threads can’t change its state. On the other hand, StringBuilder isn’t thread-safe.

91
Q

What are the different ways that you can call setState ?

A

Object Argument:
this.setState({ counter: this.state.counter + 1 });

Function Argument (with prevState):
this.setState((prevState) => ({ counter: prevState.counter + 1 }));

Function Argument (with props):
this.setState((prevState, props) => ({ counter: prevState.counter + props.increment }));

92
Q

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

A

The Virtual DOM allows React to batch multiple updates together, reducing the number of actual DOM operations and improving performance.
React’s Diffing Algorithm uses the Virtual DOM to selectively render only the necessary changes, avoiding unnecessary re-renders and DOM manipulations.

93
Q

Differentiate between Real DOM and Virtual DOM

A

Real DOM:

-It’s the actual webpage structure that you see in the browser.
-Changes directly affect what you see on the screen.
-Updating it can be slow and inefficient, especially for large pages.

Virtual DOM:

-It’s a lightweight copy of the Real DOM stored in memory.
-Changes are made to this copy first, not directly to the browser.
-It’s faster and more efficient to update because it’s done in memory.
-Once changes are made, they’re compared with the Real DOM and only necessary updates are applied to the actual webpage.

94
Q

How different is React’s ES6 syntax when compared to ES5?

A

React’s ES6 syntax differs from ES5 in several key aspects, offering more modern and concise ways to write code.
-Class Components - ES6 introduced the class syntax, allowing for the definition of React components as classes.
-Arrow Functions - ES6 arrow functions (=>) provide a more concise syntax for defining functions, with a lexical this binding. This helps to avoid common pitfalls related to the this keyword in JavaScript.
-Template Literals - ES6 template literals allow for easier string interpolation and multiline strings compared to string concatenation or line breaks in ES5.
-Let and Const - ES6 introduced let and const for variable declarations, providing block-scoping and immutable bindings, respectively.

95
Q

What do you understand from “In React, everything is a component.”

A

Components are the building blocks of a React application’s UI. These components split up the entire UI into small independent and reusable pieces.

96
Q

Explain the purpose of render() in React.

A

In React, the render() method is a crucial part of class components. Its primary purpose is to define the structure and appearance of the component’s UI based on its current state and props. When React renders a component, it invokes the render() method to generate a virtual representation of the component’s UI elements, which is then converted into actual DOM elements and displayed on the screen.

97
Q

How can you embed two or more components into one?

A

To embed two or more components into one in React, you can simply include them within the JSX markup of a parent component.

98
Q

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

A

An arrow function in React is simply a JavaScript function defined using the arrow function syntax (=>). Arrow functions provide a concise and cleaner way to define functions, especially when dealing with React components.

99
Q

Differentiate between stateful and stateless components.

A

Stateful Components:
-Also known as class components, stateful components are JavaScript classes that extend React.Component.
-They have their own internal state, managed using this.state and can modify it using this.setState().
-Stateful components can contain lifecycle methods such as componentDidMount, componentDidUpdate, and componentWillUnmount.
-They are used when a component needs to manage and update its own state, handle user interactions, or perform side effects.

Stateless Components:
-Also known as functional components, stateless components are plain JavaScript functions that accept props as arguments and return JSX.
-They do not have internal state and do not use lifecycle methods.
-Stateless components are used for presenting UI based solely on props passed to them. They are essentially “dumb” components.
-They are simpler, easier to read, and promote better code organization.

100
Q

What do you know about controlled and uncontrolled components?

A

In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by the DOM itself. To write an uncontrolled component, instead of writing an event handler for every state update, you can use a ref to get form values from the DOM.

101
Q

Why is Switch component used in React Router v4?

A

The Switch component in React Router v4 is used to exclusively render the first matching route. This means that once a route inside a Switch component matches the URL, it stops evaluating other routes and renders the matched component.

102
Q

List the advantages of ReactRouter.

A

you can create dynamic routes that respond to changes in the application’s state or user input, delivering a seamless and interactive user experience. React Router supports a variety of features, including nested routes, route parameters, programmatic navigation, and more.

103
Q

How is React Router different from conventional routing?

A

In React routing, the users feel like they are navigating across distinct webpages while in actuality they aren’t. But, in case of conventional routing, the user actually navigates across different web pages for each individual view.

104
Q

What is a constructor? Is it required?

A

Constructors are methods that are automatically executed every time you create an object. The purpose of a constructor is to construct an object and assign values to the object’s members. A constructor takes the same name as the class to which it belongs, and does not return any values.

105
Q

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

A

When dealing with promises in JavaScript, you can handle them in two main ways: using .then() or using async/await. Here’s a simplified comparison:

1.Using .then():

-With .then(), you chain methods to handle the resolved or rejected states of a promise.
-It’s a more traditional way of handling promises and is suitable for scenarios where you need to execute multiple asynchronous operations sequentially.

2.Using async/await:

-With async/await, you can write asynchronous code that looks synchronous, making it easier to understand and maintain.
-You mark a function as async to use await inside it to wait for a promise to resolve or reject.
-It’s particularly useful when you need to work with multiple asynchronous operations concurrently or when you want to simplify error handling.

106
Q

Which of these are required properties of the object in your package.json file?

A

In your package.json file, the following properties are required:

1.name: The name of your package.
2.version: The version of your package.
3.dependencies or devDependencies: At least one of these should be present to specify the dependencies of your package.

The name and version properties are essential for identifying and managing your package, while specifying dependencies is crucial for ensuring that your package can be properly installed and used within other projects.

107
Q

Can different versions of the same package be used in the same application?

A

Yes, it’s possible to use different versions of the same package within the same application. This can happen when different parts of the application require different versions of a dependency, or when dependencies of dependencies have conflicting version requirements.

However, managing multiple versions of the same package can lead to complexity and potential issues such as increased bundle size and dependency conflicts. It’s generally recommended to try to minimize the use of multiple versions of the same package and to resolve version conflicts wherever possible to maintain consistency and avoid unexpected behavior in the application.

108
Q

In package.json, how can you ensure that only patch version updates are accepted when npm install is run? (i.e. upgrading from 2.3.0 to 2.3.1 is okay, but not 2.4.0 or greater)

A

You can ensure that only patch version updates are accepted by specifying the exact version or using the tilde (~) operator in your package.json file.

109
Q

How come when you declare a variable in any js or jsx file outside of any class, object, or function, it’s not really global to all other files, components?

A

When you declare a variable in a JavaScript or JSX file outside of any class, object, or function, it is scoped to that file only and is not accessible in other files by default. This is because JavaScript uses lexical scoping, which means variables are only accessible within the block of code in which they are defined or declared.

If you want a variable to be accessible across multiple files or components, you can use module-level scope by exporting and importing the variable. In JavaScript, you can export variables, functions, or classes from one file and import them into another file where you need to use them.

110
Q

How would you enforce validation in .NET?

A

One common approach is to use data annotations provided by the System.ComponentModel.DataAnnotations namespace. These annotations can be applied to model properties to specify validation rules such as required fields, string length, range, regular expressions, etc