The typeof operator in JavaScript returns 'object' for ________.
- null
- undefined
- arrays
- functions
In JavaScript, the typeof operator returns 'object' when used with the value null. This can be a source of confusion because null is not actually an object; it's a primitive value with its own data type.
Named imports in JavaScript must match the exported names in the module, unless they are ________.
- Renamed
- Aliased
- Excluded
- Deprecated
Named imports in JavaScript must match the exported names in the module, unless they are "aliased." When you alias an import, you can give it a different name than the exported name, providing flexibility in your code.
In Express.js, the :id? in a route path like "/users/:id?" denotes that id is a(n) ______ parameter.
- optional
- required
- query
- body
In Express.js, the :id? in a route path like "/users/:id?" denotes that id is an optional parameter. This means that the id parameter may or may not be present in the URL, and the route will still match. The other options are not correct in this context (required would mean the parameter is mandatory, query is used for query parameters, and body is used for request bodies).
To serve static files such as images, CSS files, and JavaScript files, a special folder called ______ is commonly used in Express.js.
- public
- assets
- static
- files
To serve static files such as images, CSS files, and JavaScript files, a special folder called the public folder is commonly used in Express.js. This folder typically contains all your publicly accessible static assets.
Which of the following is a property of the Global Object in Node.js?
- console
- globalThis
- module
- require
In Node.js, the global object is a global context object that contains various properties and methods available throughout the application. globalThis is a reference to the global object, which allows cross-environment compatibility. console, module, and require are not properties of the global object but are commonly used in Node.js for various purposes.
What is the primary difference between OAuth 1.0 and OAuth 2.0?
- OAuth 1.0 uses HMAC-SHA1 for signing requests, while OAuth 2.0 uses JWT.
- OAuth 1.0 requires client registration, while OAuth 2.0 does not.
- OAuth 1.0 uses two-legged authentication, while OAuth 2.0 uses three-legged authentication.
- OAuth 1.0 is a token-based system, while OAuth 2.0 is a protocol for token-based authentication.
The primary difference is that OAuth 1.0 requires client registration, while OAuth 2.0 does not. OAuth 2.0 introduced a more streamlined and flexible approach to authorization. The other options describe differences but not the primary distinction.
What is a consumer?
- A component that provides a context value
- A component that consumes a context value
- A component that renders children conditionally
- A component that handles user events
In React context, a consumer is a component that consumes a context value. The consumer component allows child components to access the context value without the need to pass props explicitly. Consumers can be implemented using the useContext() hook or the Consumer component, which provides a render prop that can be used to consume the context value.
What is Formik?
- A React library for working with forms
- A testing library for React
- A utility library for working with arrays
- An animation library for React
Formik is a utility library for working with forms in React. It provides a simple and flexible way to handle form validation, input masking, and submission handling. Formik also integrates with other popular form libraries, such as Yup and React-Select.
What are React Mixins?
- Components that are composed of other components
- Methods for handling async operations in React
- Reusable code snippets that can be applied to multiple components
- Techniques for improving the performance of React applications
React Mixins are reusable code snippets that can be applied to multiple components in order to provide shared functionality. They are a way to encapsulate logic and behavior that can be used across multiple components, allowing for code reuse and reducing duplication. However, they are not recommended in modern versions of React and have been largely replaced by higher-order components and render props.
What are loadable components?
- A component that loads data asynchronously
- A component that loads other components asynchronously
- A component that loads itself asynchronously
- A component that loads CSS stylesheets asynchronously
Loadable components are a way to load other components asynchronously in React. Loadable components allow components to be split into smaller chunks and loaded on-demand, improving performance and reducing initial load times. Loadable components are typically used with dynamic imports to enable asynchronous loading of code.