HTML5 introduces new elements and attributes, supports multimedia, and enhances semantics. It provides better integration with JavaScript and CSS, improving the overall web development experience.
The box model comprises content, padding, border, and margin. It defines how these elements contribute to the total space an element occupies on a webpage.
Specificity determines which CSS rule takes precedence. It is based on the selector's specificity, where inline styles have the highest specificity, followed by IDs, classes, and elements.
A closure is a function that retains access to variables from its outer (enclosing) scope even after that scope has finished execution. It allows for data encapsulation and is a key concept in JavaScript.
let and const are block-scoped, while var is function-scoped. const is used for constants, and let allows reassignment. var is an older way of declaring variables.
In JavaScript, 'this' refers to the current execution context. Its value depends on how a function is called, whether it's a method, a function, or an event handler.
The viewport meta tag controls how a web page is displayed on a device. It enables responsiveness by adapting the layout to the device's screen size.
Event delegation involves assigning a single event listener to a common ancestor of multiple elements. It utilizes event bubbling to handle events on child elements.
Responsive web design ensures that a website looks and functions well on various devices and screen sizes. It uses fluid grids, flexible images, and media queries to achieve adaptability.
The 'async' attribute in script tags tells the browser to execute the script asynchronously, allowing the HTML parsing to continue without waiting for the script to finish downloading and executing.
== is the equality operator that performs type coercion, while === is the strict equality operator that checks both value and type without coercion.
Using the combination of position: absolute, top: 50%, left: 50%, transform: translate(-50%, -50%) can center an element both horizontally and vertically.
The z-index property determines the stacking order of positioned elements. It controls which element appears in front when elements overlap.
The 'defer' attribute in script tags delays the execution of the script until the HTML parsing is complete. It ensures that the script is executed in order after the HTML is fully loaded.
Both localStorage and sessionStorage store key-value pairs, but sessionStorage data is session-specific and is cleared when the session ends. localStorage data persists across sessions.
The clearfix hack is used to contain floated elements within a parent element. It prevents the parent element from collapsing when all its child elements are floated.
The 'box-sizing' property defines how the total width and height of an element are calculated. The default is 'content-box,' but it can be set to 'border-box' to include padding and border in the total size.
You can prevent the default behavior using the event.preventDefault() method in a JavaScript event listener. This is often used to stop the anchor from navigating to a new page.
CORS is a security feature implemented by web browsers to control requests made to a different domain. It ensures that a web page can make requests only to its own domain by default, preventing cross-origin security vulnerabilities.
The 'role' attribute is used to define the purpose or type of an element, especially for accessibility. It helps assistive technologies understand the structure and function of the content.
React.js is a JavaScript library for building user interfaces, particularly for creating single-page applications where UI updates efficiently and dynamically in response to user actions.
JSX is a syntax extension for JavaScript recommended by React. It allows you to write HTML elements and components in a JavaScript file, making it more readable and convenient.
Virtual DOM is a lightweight copy of the actual DOM. React uses it to improve performance by updating only the parts of the actual DOM that need changes.
React components are reusable, self-contained modules that manage a part of the UI. They can be either class components or functional components.
State is managed within a component and can be changed, while props are external inputs to a component that cannot be modified by the component itself.
: Controlled components are components whose value is controlled by React. They receive their current value through props and notify changes via callbacks.
: Keys help React identify which items have changed, are added, or are removed. They should be unique within a list to ensure efficient DOM updates.
: Lifting state up involves moving the state from child components to their common parent. This helps in sharing state among sibling components.
componentDidMount is invoked immediately after a component is mounted. It is used for tasks that require interaction with the DOM or AJAX requests.
React uses camelCase for event names, and event handlers are passed as functions. For example, onClick instead of onclick.
shouldComponentUpdate allows a component to prevent unnecessary re-rendering by returning false if the component does not need to update.
Redux is a state management library used with React to manage the state of an entire application in a predictable and centralized manner.
Class components use ES6 class syntax and have their own state, while functional components are stateless and use the useState hook for state management.
React Router is a standard library for navigation in React applications. It enables the navigation among views of various components in a React Application, allows changing the browser URL, and keeps UI in sync with the URL.
HOC is a pattern where a function takes a component and returns a new component with additional functionalities. It is used for code reuse, logic abstraction, and prop manipulation.
Redux Thunk is middleware for Redux that allows handling asynchronous actions by delaying the dispatch of an action until a later time.
The lifecycle methods in React are componentDidMount, componentDidUpdate, componentWillUnmount, etc., used to perform actions at different stages of a component's existence.
Performance optimization in React involves using shouldComponentUpdate, PureComponent, memoization, and code splitting.
React Hooks are functions that let you use state and other React features in functional components instead of class components.
Context provides a way to pass data through the component tree without having to pass props down manually at every level. It is used for sharing values like themes, authentication status, etc.
Node.js is an open-source, cross-platform JavaScript runtime environment that executes JavaScript code server-side. It allows developers to build scalable and efficient network applications.
Node.js is event-driven, meaning it operates based on events and callbacks. Asynchronous events trigger the execution of functions, enhancing scalability by efficiently handling numerous connections simultaneously.
npm (Node Package Manager) is the default package manager for Node.js. It facilitates the installation, sharing, and management of third-party libraries, frameworks, and tools.
Node.js uses an event loop to handle asynchronous operations. It executes non-blocking I/O operations, allowing the program to continue processing other tasks while waiting for I/O operations to complete.
package.json contains metadata about the Node.js application, including dependencies, scripts, and project details. It's essential for managing project configurations and dependencies.
Callback hell refers to the nested structure of callbacks, leading to unreadable and complex code. To mitigate it, developers use techniques like modularization, named functions, or adopting Promises and async/await.
The 'require' function is used to import modules in Node.js. It allows the inclusion of external modules or libraries into the current application, enhancing code modularity and reusability.
Middleware in Node.js refers to functions that have access to the request and response objects. It can modify these objects, execute code, and terminate the request-response cycle. Middleware is crucial for tasks like authentication, logging, and error handling.
The 'exports' object is used to expose variables, functions, or objects from a module to be accessible in other modules. It helps create reusable and modular code.
'process.nextTick()' executes a callback function after the current event loop cycle, while 'setImmediate()' executes a callback in the next iteration of the event loop.
Streams in Node.js provide an efficient way to handle data flow. They allow reading or writing data in chunks, reducing memory usage and enhancing performance.
The 'Buffer' class is used to handle binary data in Node.js. It provides a way to work with raw binary data directly, making it essential for tasks like file system operations and network communication.
Node.js utilizes a single-threaded event loop to handle multiple concurrent connections efficiently. It avoids blocking operations, ensuring that the application remains responsive.
Clustering in Node.js involves the creation of multiple worker processes to share the application's load. It improves performance by utilizing multiple CPU cores.
The 'global' object in Node.js represents the global scope. Variables declared without the 'var', 'let', or 'const' keyword become part of the 'global' object.
Node.js can create child processes using the 'child_process' module. It enables the execution of system commands and other Node.js scripts in separate processes.
Express is a web application framework for Node.js. It simplifies the development of web applications by providing a robust set of features for routing, middleware, and handling HTTP requests and responses.
WebSocket is a communication protocol that provides full-duplex communication channels over a single TCP connection. In Node.js, it's often used for real-time applications, enabling bidirectional communication between the client and server.
Securing a Node.js application involves measures like using HTTPS, validating user input, implementing authentication and authorization, and keeping dependencies up-to-date.
'Pug' (formerly Jade) is a templating engine used with Express.js to simplify HTML generation. It offers a concise and expressive syntax for writing templates.
PHP stands for Hypertext Preprocessor. It is a server-side scripting language used for web development to create dynamic and interactive web pages.
Both include and require are used to include files, but require will produce a fatal error if the file is not found, whereas include will only produce a warning.
Both echo and print are used to output data in PHP. The key difference is that echo can take multiple parameters, while print can only take one, and print always returns 1, so it can be used in expressions.
GET is used to send data to the server as part of the URL, while POST sends data in the HTTP request body. GET is less secure and has limitations on the amount of data that can be sent, while POST is more secure and can handle larger amounts of data.
mysql is an improved version of the original MySQL extension and provides various enhancements, including support for prepared statements, transactions, and better security features.
Superglobals are built-in variables that are always accessible, regardless of scope. Examples include $_GET, $_POST, $_SESSION, and $_GLOBALS.
isset() is used to determine if a variable is set and is not null. It returns true if the variable exists and is not null; otherwise, it returns false.
session_start() is used to initialize a session in PHP. It must be called before any output is sent to the browser, and it starts or resumes a session based on a session identifier passed via a GET or POST request or a cookie.
Sessions store user information on the server, identified by a session ID, while cookies store information on the user's computer. Sessions are more secure but require server resources, while cookies are less secure but are stored on the client side.
PDO (PHP Data Objects) is a database access layer providing a uniform method of access to multiple databases. It allows developers to write database-independent code.
Namespaces are used to avoid naming conflicts between different parts of a program. They provide a way to organize code into logical groups and prevent naming collisions.
Both array() and [] are used to create arrays in PHP. The [] syntax is a shorthand introduced in PHP 5.4 for creating arrays.
The == operator checks for equality in values, while the === operator checks for both equality in values and equality in data types.
The __construct() method is a special method in PHP classes that is automatically called when an object is created. It is commonly used for initializing object properties.
The header() function is used to send raw HTTP headers in PHP. It is often used for redirection or sending specific headers like content type.
try is used to enclose code that might throw an exception. catch is used to handle the exception if one is thrown. finally is used to specify code that will be executed regardless of whether an exception is thrown or caught.
The unlink() function is used to delete a file in PHP. It takes the filename as its argument and returns true on success or false on failure.
Autoloading is a feature in PHP that automatically includes the necessary class files when a class is instantiated, eliminating the need for explicit require or include statements.
array_map() applies a callback function to each element of one or more arrays, returning an array of the results. It is useful for performing an operation on corresponding elements of multiple arrays.
To prevent SQL injection, use prepared statements and parameterized queries with either the mysql or PDO extension. Avoid using user input directly in SQL queries.