InterviewQuestionJS-React-CSS-html
InterviewQuestionJS-React-CSS-html
----------------------------------------------------------------
1. What are non primitive data types and primitve data types
Ans: Non-primitive: array, object, functions
Primitive : string, number, null, undefined, boolean
2. how do you extract only alphabets from the below string using regular expresion
or tell him his wish?
var str = "Wel34#%*com5e" // Welcome
Ans: str.replace(/[^a-zA-Z]/gi, '') or diff solutions
3. using below data how do you play random song from below array list?
var data = ["song1.mp3", "song2.mp3", "song3.mp3", "song4.mp3", "song5.mp3"]
Ans: data[Math.floor(Math.random() * data.length)]
4. how to increment and decrement a value. open below link write a program with out
using
any global variable (give below link to candidate)
https://codesandbox.io/s/increment-decrement-in-js-forked-pfvzhc?file=/
index.html
5. reverse string with out using any predefined methods like split reverse join-
using prototype develop program
Ans: String.prototype.rev = function() {
var str = "";
for(var i=this.length-1; i>=0 ; i--) {
str += this[i]
}
return str;
}
//"govind".rev() // dnivog
6. What is recursive function and using recurisve strategy how do you add one or
more disabled parameter to the below data
(if you want create in react js also)
var data = [
{
name: "General",
children: [
{
name: "Account",
children: []
}
]
},
{
name: "Category",
children: [
{
name: "Subject",
children: []
}
]
}
]
output:
var outputdata = [
{
name: "General",
disabled: false,
children: [
{
name: "Account",
disabled: false,
children: []
}
]
},
{
name: "Category",
disabled: false,
children: [
{
name: "Subject",
disabled: false,
children: []
}
]
}
]
Ans:
function recursive(data) {
return data.map(x=> {
return ({
...x,
disabled: false,
children: x.children ? recursive(x.children) : []
})
})
}
OR diff solution using for loop ...etc
7. How to detect user in online or ofline using javascript
Redux:
---------------------------------------
1. What are the Redux Three Principles
- Single source of truth (store.getState())
- state is readonly (dispatch) - The only way to change the state is to emit an
action using dispatch,
- changes happen through pure functions (reducers)
2. what is usage of batch method in redux
Ans: for grouping multiple dispatch events to improve performance
3. how to handle api call using
Ans: dispatch(action1)
const action1 =() {
return (dipatch) => {
axios.get(url).then((res)=> {
dispatch({type: "actionname", payload: res})
})
}
}
4. diff between redux and redux toolkit
CSS:
---------------------------
1. What are the available combinators (important selectors)
Ans:
descendant selector (space)
child selector (>)
adjacent sibling selector (+)
general sibling selector (~)
2. css browser prefixes
Ans: -webkit-, -moz-, -ms-, -o-
3. diff between flex-shrink and flex-basis
HTML:
-What are the semantic and non-semantic elements
Ans: Semantic: article, main, section, header, footer, nav ...etc
Non-semantic:div, span
-What are available new form control elements
-What are the availble web storages
Ans: local storage and session storage
-what is diff between session and local storages
https://www.workfall.com/learning/blog/how-to-build-a-hybrid-app-using-react-
native/
4 and below
JS
---------------
-What is implicity type conversion and explicity type conversion
Ans: implicity is done by javascript like alert(8.2); cancatenaton, substraction
tow strings, modululo(%)
Explicity is done by using inbuilt methods like toString, Number, parseInt,
String ..etc
-data types
-increment and decrement program
-string methods
-remove duplicates array using for loop
-array strings random value print
-string reverse with out prdefined methods
-self invoking function
-diff between for IN and for OF
-how to iterate object
-how to
function pnt(n) {
for(var row=1; row<=n; row++) {
for(var col=1; col<=row; col++) {
console.log("* ")
}
console.log("")
}
}
event-listner-dmk95p
Custom hook
const useBoolean = () => {
const [state, setState] = React.useState();
return [
state,
{
handleTrue,
handleFalse,
handleFalse,
},
];
};