javascript React - take the quiz

What is the main purpose of React?
To create user interfaces
To build web applications
To write server-side code
To debug JavaScript code
What does JSX stand for?
JavaScript XML
Java Script eXtension
JavaScript Extension
Java Script Xpress
How do you pass data from a parent component to a child component in React?
Props
State
Context
Refs
What is the correct syntax for declaring a function in JavaScript?
function myFunction  {...}
var myFunction = () => {...}
let myFunction = {...}
const myFunction = () -> {...}
What is the name of the method that is called when a component is first created?
render()
init()
constructor()
mount()
What is the difference between an element and a component in React?
An element is a plain object representation of a DOM node while a component is a class or function that produces elements
An element is a class or function while a component is a plain object representation of a DOM node
An element is a plain object representation of a DOM node while a component is a string
An element is a string while a component is a class or function
What is the purpose of the useEffect hook in React?
To perform side effects after a component has been rendered
To update the state of a component
To handle events in a component
To initialize a component
which of the following is NOT true about react props
props help passing information from a parent component to a child component via a component element’s HTML attribute
Props are used to pass information up the component tree
the passed variables can be accessed in the child component as a property from the props object
props does not pass information from a child to a parent component
calling useState() would return:
an array of two variables: one representing the currect state and a function to update the current state
two strings
a promise
none
react state is used to make applications interactive and alter information over time
True
False
useState() is a
side effect
promise
hook
javascript object
a function that has its signature in a parent component and called by a child component via props is :
an inline function
a callback handler
an event handler
none of the above
callback handlers are used to communicate up the component tree
True
False
lifting the state up:
moving the state from a child component to the parent component
allows other child component to access the state
requires a callback handler if a child component wants to manage the state
all of the above
extracting data from javascript objects can be done through :
props
children
object destructuring
fetch( )
Variables created with object distructuring can only be named after the keys of the object
True
False
Destructuring the props object in the function signature of the component
makes the code confusing
requires Refactoring the component's arrow function from concise body to block body
makes the code repetetive
none of the above
the props object is as follows {title:'react', id:13} to access these values in a child component:
const App ( { title,id } )=>{...}
const App ()=>{ const { title , id }=props ; }
const App ()=>{ const newTitle=props.title ; const newId=props.id ; }
all of the above
which of the following is not a side-effect :
storing data in the browser's local storage
data fetching
updating the state of the component
requesting data from remote APIs or servers
React side-effect is anything that is outside the scope of React
True
False
which of the following is not a method for js localStorage :
getItem()
searchItem()
removeItem()
setItem()
which of the following is not a method for js localStorage :
getItem()
searchItem()
removeItem()
setItem()
const test=true;
test ? console.log('passed') : console.log('denied') ;
 
output : passed
output : denied
output : passed denied
output : error
useEffect() takes 2 arguments : a function that runs the side-effect and a dependency array
True
False
The dependancy array of the usestate() hook :
if it's not included, the side-effect function will run on every render
if it's empty, the side-effect function will only run once after the component renders for the first time
triggers the side-effect function everytime its content changes
all of the above
const Parent=()=>{
return(
<Child> hello world </Child>
); };
 
contst Child=({children})=>{
return(
<h1> {children} </h1>
); };
output : children
output : hello world
output : error
none of the above
children prop in react :
makes the component elements behave similarly to native HTML
makes it possible to control a component's XML directly from its instantiation
Anything passed between component elements can be accessed as children in the component
all of the above
<button  id='removeb'  onClick={removeItem(item)} >
removeItem() will execute when the button is clicked
this will cause an infinite loop as the removeItem() is called and not being passed
removeItem() is passed as props
none of the above
all of these are alternatives to pass an event handler function with a parameter exept :
onClick={removeItem(item)}
onClick={()=>removeItem(item)}
onclick={removeItem.bind(null,item)}
const remove=()=>{ removeItem(item)}; return( ...
Asynchronous data is data delivered instantly
True
False
delays in data arrival can be handled using :
props
side-effects
promise
callback handlers
promise errors are handled via :
resolve()
reject()
catch()
throw new Error
setTimeOut() is used for :
blocking data
fetching data
simulating data arrival delays
resolving promises
{ test &&

hello world

} is equivalent to :
test +

hello world

if (test==true) {

hello world

}
if (test==true AND p=='hello world') {return}
this syntax is not valid
The '&&' (AND) operator and the ternary( ...? .... : ...) operator are used for conditional rendering :
True
False
fetch() return :
an object
a string
a promise
a list of objects
 const ch1='ahmad mohsen' ;
 const ch2='piw piw' ;
const ch3=`${ch1}${ch2}` ;
 
ch3='ahmadmohsenpiwpiw'
ch3=' '
ch3 ='ahmad mosen piw piw'
none of the above
fetch() takes 2 arguments to retrieve data from an API
a url and a dependency array
two strings
state and a state handler
promise and a dependency array
0
{"name":"javascript React - take the quiz", "url":"https://www.quiz-maker.com/Q0UQZXJ5H","txt":"What is the main purpose of React?, What does JSX stand for?, How do you pass data from a parent component to a child component in React?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker