1In ES6, which keyword is used to declare a variable that cannot be reassigned?
A.var
B.let
C.const
D.static
Correct Answer: const
Explanation:The 'const' keyword is used to declare variables that are meant to remain constant and cannot be reassigned after their initial declaration.
Incorrect! Try again.
2What is the scope of a variable declared using the 'let' keyword?
A.Global scope
B.Function scope
C.Block scope
D.Module scope
Correct Answer: Block scope
Explanation:Variables declared with 'let' are limited to the block, statement, or expression on which it is used, unlike 'var' which is function scoped.
Incorrect! Try again.
3Which of the following is the correct syntax for an Arrow Function in ES6?
A.function name() {}
B.const name = () => {}
C.const name -> {}
D.name() => {}
Correct Answer: const name = () => {}
Explanation:Arrow functions use the '=>' syntax. A common way to define them is assigning them to a constant.
Incorrect! Try again.
4How does the 'this' keyword behave differently in Arrow Functions compared to regular functions?
A.It has its own binding to 'this'
B.It inherits 'this' from the surrounding code (lexical scoping)
C.It always refers to the global object
D.It is undefined
Correct Answer: It inherits 'this' from the surrounding code (lexical scoping)
Explanation:Arrow functions do not have their own 'this'. They inherit 'this' from the parent scope at the time they are defined.
Incorrect! Try again.
5Which Array method creates a new array by applying a function to every element in the calling array?
A.forEach
B.filter
C.map
D.reduce
Correct Answer: map
Explanation:The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.
Incorrect! Try again.
6What does the Array.prototype.filter() method return?
A.The first element that matches the condition
B.A boolean value
C.A new array with all elements that pass the test
D.The modified original array
Correct Answer: A new array with all elements that pass the test
Explanation:filter() creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.
Incorrect! Try again.
7Which method checks if all elements in an array pass a specific test?
A.some()
B.every()
C.filter()
D.check()
Correct Answer: every()
Explanation:The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
Incorrect! Try again.
8What is the primary purpose of the Array.prototype.reduce() method?
A.To filter the array
B.To loop through the array
C.To reduce the array to a single value
D.To reverse the array
Correct Answer: To reduce the array to a single value
Explanation:The reduce() method executes a reducer function on each element of the array, resulting in a single output value.
Incorrect! Try again.
9Which ES6 feature allows you to unpack values from arrays or properties from objects into distinct variables?
A.Spread Operator
B.Rest Operator
C.Destructuring
D.Hoisting
Correct Answer: Destructuring
Explanation:Destructuring assignment is a syntax that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
Incorrect! Try again.
10What is the output of the following code: const [a, b] = [1, 2]; console.log(b);?
A.1
B.2
C.[1, 2]
D.undefined
Correct Answer: 2
Explanation:This is array destructuring. The variable 'b' is assigned the second value of the array, which is 2.
Incorrect! Try again.
11Which operator is indicated by three dots (...) and expands an iterable into individual elements?
A.Rest Operator
B.Spread Operator
C.Ternary Operator
D.Dot Operator
Correct Answer: Spread Operator
Explanation:The Spread operator (...) allows an iterable such as an array or string to be expanded in places where zero or more arguments or elements are expected.
Incorrect! Try again.
12In the context of function arguments, what does the Rest operator (...) do?
A.Expands an array into arguments
B.Collects multiple arguments into a single array
C.Copies the object
D.Returns the remainder of a division
Correct Answer: Collects multiple arguments into a single array
Explanation:The Rest parameter syntax allows a function to accept an indefinite number of arguments as an array.
Incorrect! Try again.
13How do you define a class in ES6?
A.class MyClass {}
B.function class MyClass() {}
C.type MyClass {}
D.define MyClass {}
Correct Answer: class MyClass {}
Explanation:ES6 introduced the 'class' keyword to define classes, which is primarily syntactical sugar over JavaScript's existing prototype-based inheritance.
Incorrect! Try again.
14Which keyword is used to inherit a class from another class?
A.implements
B.inherits
C.extends
D.super
Correct Answer: extends
Explanation:The 'extends' keyword is used in class declarations or class expressions to create a class that is a child of another class.
Incorrect! Try again.
15What is the purpose of the 'export default' syntax in ES6 Modules?
A.To export multiple values
B.To export a single main value from a module
C.To import a module
D.To delete a module
Correct Answer: To export a single main value from a module
Explanation:export default is used to export a single class, function, or primitive from a script file, which can be imported without using curly braces.
Incorrect! Try again.
16How do you import a named export 'data' from a module 'file.js'?
A.import data from './file.js'
B.import { data } from './file.js'
C.require(data) from './file.js'
D.fetch data from './file.js'
Correct Answer: import { data } from './file.js'
Explanation:Named exports must be imported using curly braces matching the export name.
Incorrect! Try again.
17Which method creates a new Array instance from an array-like or iterable object?
A.Array.of()
B.Array.create()
C.Array.from()
D.Array.new()
Correct Answer: Array.from()
Explanation:Array.from() lets you create Arrays from array-like objects (objects with a length property and indexed elements) or iterable objects.
Incorrect! Try again.
18What does the Array.prototype.find() method return?
A.The index of the element
B.A new array
C.The first element satisfying the condition
D.True or False
Correct Answer: The first element satisfying the condition
Explanation:The find() method returns the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.
Incorrect! Try again.
19The Array.prototype.concat() method is used to:
A.Remove the last element of an array
B.Merge two or more arrays
C.Sort the array
D.Filter the array
Correct Answer: Merge two or more arrays
Explanation:The concat() method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.
Incorrect! Try again.
20What is a Single Page Application (SPA)?
A.A website that uses only one HTML tag
B.An app that reloads the page on every click
C.An app that dynamically rewrites the current web page with new data from the web server
D.An application that runs offline only
Correct Answer: An app that dynamically rewrites the current web page with new data from the web server
Explanation:An SPA interacts with the user by dynamically rewriting the current web page with new data from the web server, rather than the default method of the browser loading entire new pages.
Incorrect! Try again.
21What is a major difference between SPA and MPA (Multi-Page Application)?
A.SPA is slower than MPA
B.MPA reloads the page for every request, SPA does not
C.SPA uses HTML, MPA does not
D.There is no difference
Correct Answer: MPA reloads the page for every request, SPA does not
Explanation:In an MPA, the browser downloads a fresh page on every interaction. In an SPA, the page does not reload; content is updated dynamically via JavaScript.
Incorrect! Try again.
22Which company maintains ReactJS?
A.Google
B.Facebook (Meta)
C.Microsoft
D.Twitter
Correct Answer: Facebook (Meta)
Explanation:React is an open-source front-end JavaScript library for building user interfaces or UI components maintained by Facebook (Meta).
Incorrect! Try again.
23What is the standard command to create a new React project using Create React App?
A.npm new react-app my-app
B.npx create-react-app my-app
C.npm install create-react-app
D.node create-react my-app
Correct Answer: npx create-react-app my-app
Explanation:npx create-react-app my-app is the standard command to scaffold a new React project using the Create React App tool.
Incorrect! Try again.
24Which build tool is known for being faster than Webpack and is often used as an alternative to Create React App?
A.Vite
B.Gulp
C.Grunt
D.Babel
Correct Answer: Vite
Explanation:Vite is a build tool that significantly improves the frontend development experience, offering faster server start and hot module replacement compared to Webpack (used by CRA).
Incorrect! Try again.
25Which folder in a React project structure typically contains images, index.html, and the manifest file?
A.src
B.public
C.node_modules
D.build
Correct Answer: public
Explanation:The 'public' folder contains static assets like the HTML file and images that are not processed by Webpack's module system.
Incorrect! Try again.
26In a standard React folder structure, where does the source code (components, styles) primarily reside?
A.root
B.public
C.src
D.dist
Correct Answer: src
Explanation:The 'src' (source) directory is where the developer writes the React components, CSS, and application logic.
Incorrect! Try again.
27What is 'node_modules' in a React environment?
A.Your custom components
B.The folder containing all installed npm dependencies
C.The production build folder
D.The folder for unit tests
Correct Answer: The folder containing all installed npm dependencies
Explanation:node_modules is the repository where npm or yarn stores the external libraries and packages required by the project.
Incorrect! Try again.
28What does JSX stand for?
A.JavaScript XML
B.Java Syntax Extension
C.JSON Xchange
D.JavaScript Xhtml
Correct Answer: JavaScript XML
Explanation:JSX stands for JavaScript XML. It is a syntax extension for JavaScript that looks similar to XML or HTML.
Incorrect! Try again.
29Can browsers understand JSX directly?
A.Yes, all modern browsers support it
B.No, it must be transpiled to regular JavaScript
C.Only Chrome supports it
D.Yes, if the file extension is .jsx
Correct Answer: No, it must be transpiled to regular JavaScript
Explanation:Browsers cannot read JSX. It needs to be transformed into standard JavaScript objects (using tools like Babel) before the browser can understand it.
Incorrect! Try again.
30In React, what is the equivalent of the HTML 'class' attribute in JSX?
A.class
B.className
C.styleClass
D.cssClass
Correct Answer: className
Explanation:Since 'class' is a reserved keyword in JavaScript, JSX uses 'className' to define CSS classes for elements.
Incorrect! Try again.
31What method is strictly used to render a React element into the DOM in older React versions (before React 18)?
A.ReactDOM.render()
B.React.render()
C.ReactDOM.mount()
D.document.render()
Correct Answer: ReactDOM.render()
Explanation:ReactDOM.render() was the standard method to render React components into the DOM before React 18 introduced createRoot.
Incorrect! Try again.
32Which function is implicitly called when you write JSX tags?
A.React.makeElement
B.React.createElement
C.document.createElement
D.React.compile
Correct Answer: React.createElement
Explanation:JSX code is compiled into calls to React.createElement().
Incorrect! Try again.
33What are the first three arguments of React.createElement()?
A.props, type, children
B.type, children, props
C.type, props, children
D.children, type, props
Correct Answer: type, props, children
Explanation:The signature is React.createElement(type, [props], [...children]). Type is the tag name, props are attributes, and children are content.
Incorrect! Try again.
34How do you embed a JavaScript expression inside JSX?
A.Inside double quotes " "
B.Inside square brackets [ ]
C.Inside curly braces { }
D.Inside parentheses ( )
Correct Answer: Inside curly braces { }
Explanation:Curly braces { } are used to embed valid JavaScript expressions, variables, or logic within JSX.
Incorrect! Try again.
35Which of the following is a valid way to write an inline style in JSX?
A.style="color: red;"
B.style={color: "red"}
C.style={{ color: "red" }}
D.style={ "color": "red" }
Correct Answer: style={{ color: "red" }}
Explanation:In JSX, the style attribute accepts a JavaScript object. The outer braces represent the JSX expression, and the inner braces denote the object.
Incorrect! Try again.
36Component names in React must start with:
A.A lowercase letter
B.An uppercase letter
C.An underscore
D.A dollar sign
Correct Answer: An uppercase letter
Explanation:React treats components starting with lowercase letters as DOM tags. User-defined components must be capitalized.
Incorrect! Try again.
37What is the main advantage of using JSX over React.createElement?
A.It runs faster
B.It is standard HTML
C.It provides a visual structure that is easier to read and write
D.It doesn't require JavaScript
Correct Answer: It provides a visual structure that is easier to read and write
Explanation:While both do the same thing ultimately, JSX is syntactic sugar that allows developers to visualize the UI structure similarly to HTML, making code more readable.
Incorrect! Try again.
38If you want to render a list of items in React, which array method is most commonly used?
A.forEach
B.map
C.filter
D.reduce
Correct Answer: map
Explanation:The map() method is used to iterate over an array of data and return an array of React elements (JSX).
Incorrect! Try again.
39What acts as the entry point to a React application created with Vite?
A.index.js
B.App.js
C.main.jsx
D.server.js
Correct Answer: main.jsx
Explanation:In Vite projects, the entry point is typically named 'main.jsx' (or 'main.tsx' for TypeScript), which mounts the app.
Incorrect! Try again.
40Which file typically contains the root DOM node <div id="root"></div>?
A.App.js
B.index.js
C.index.html
D.package.json
Correct Answer: index.html
Explanation:The public/index.html file contains the HTML boilerplate and the empty div with id='root' where React attaches the application.
Incorrect! Try again.
41In React, tags with no children (self-closing tags) must end with:
A.>
B./>
C.</>
D.?>
Correct Answer: />
Explanation:In JSX, self-closing tags must explicitly end with '/>', unlike HTML where the slash is optional for void elements.
Incorrect! Try again.
42What is the correct way to wrap multiple elements in JSX without adding an extra node to the DOM?
A.<div>
B.<React.Container>
C.<Fragment> or <>
D.<Section>
Correct Answer: <Fragment> or <>
Explanation:React Fragments (<React.Fragment> or the short syntax <>) let you group a list of children without adding extra nodes to the DOM.
Incorrect! Try again.
43What is the return type of a functional component?
A.HTML
B.JSX
C.String
D.Boolean
Correct Answer: JSX
Explanation:Functional components return JSX, which describes what the UI should look like.
Incorrect! Try again.
44Which environment is required to run the 'create-react-app' command?
A.Python
B.JDK
C.Node.js
D.Apache
Correct Answer: Node.js
Explanation:Node.js is the runtime environment required to execute npm/npx commands and run the development server.
Incorrect! Try again.
45What is the purpose of package.json in a React project?
A.It stores the database configuration
B.It lists project dependencies and scripts
C.It contains the React source code
D.It contains the HTML templates
Correct Answer: It lists project dependencies and scripts
Explanation:package.json acts as the manifest for the project, recording metadata, scripts (like start, build), and dependencies.
Incorrect! Try again.
46What does the Array.prototype.reverse() method do?
A.Sorts the array alphabetically
B.Reverses the order of elements in place
C.Creates a reversed copy
D.Filters out the last element
Correct Answer: Reverses the order of elements in place
Explanation:The reverse() method reverses an array in place. The first array element becomes the last, and the last array element becomes the first.
Incorrect! Try again.
47How do you comment inside JSX?
A.<!-- comment -->
B.// comment
C.{/ comment /}
D.# comment
Correct Answer: {/ comment /}
Explanation:Inside the JSX return block, comments must be wrapped in curly braces and use block comment syntax: {/ comment /}.
Incorrect! Try again.
48What happens if you try to render a Boolean value (true/false) in JSX?
A.It renders 'true' or 'false' as text
B.It renders 1 or 0
C.It renders nothing
D.It throws an error
Correct Answer: It renders nothing
Explanation:React does not render true, false, null, or undefined in the DOM. They are ignored.
Incorrect! Try again.
49Which attribute is used in JSX to handle the 'for' attribute of labels?
A.for
B.htmlFor
C.labelFor
D.forLabel
Correct Answer: htmlFor
Explanation:'for' is a reserved word in JavaScript (for loops), so React uses 'htmlFor' to associate a label with an input.
Incorrect! Try again.
50The 'forEach' array method returns:
A.The modified array
B.A new array
C.undefined
D.The length of the array
Correct Answer: undefined
Explanation:forEach executes a provided function once for each array element but does not return anything (returns undefined). It is used for side effects.
Incorrect! Try again.
Give Feedback
Help us improve by sharing your thoughts or reporting issues.