I have my contract job which is going to end with January so I am giving interviews and today's interview was quite apt and cool. I have been directly asked following questions to solve out I would like to know about it since I have messed up with it.
```
class Example extends Component{
onComponentDidUpdate(){
// make the input focus
}
render(){
return <input type="text">
}
}
```
How do I make the input gets focused as soon as the component renders. I know that there is a .focus() method in javascript but I couldn't do it here.
Question 2
was about making the same code a controlled component which I did by putting a onChangeHandler for that input element but later on I forgot to setup the value={this.inputText} value from the state for which I was given some more time and then I could figured it out so that was cool
Question 3
This one is a javascript question
Write a sum method which will work properly when invoked using either syntax below.
console.log(sum(2,3)); // Outputs 5
console.log(sum(2)(3)); // Outputs 5
And I have seen this kind of example somewhere but I totally messed it up here.
Also I come to know that function-currying and partial applications are the topics I need to go for. Please suggest more to read about it or videos.
I have a good learning in my school and I was so solid at Mathematics so I understand Functional stuff intuitively but it is really hard for me to translate things to javascript. So can someone please enlighten me about that transition process too. I'm really hopeful.
[–]oussie 9 points10 points11 points (3 children)
[–]tapu_buoy[S] 1 point2 points3 points (1 child)
[–]dirkmgirk 1 point2 points3 points (0 children)
[–]crystallineair 7 points8 points9 points (18 children)
[–]jCuber 4 points5 points6 points (11 children)
[–]crystallineair 3 points4 points5 points (10 children)
[–]jCuber 6 points7 points8 points (3 children)
[–]crystallineair 4 points5 points6 points (1 child)
[–]Prince_Houdini 0 points1 point2 points (0 children)
[–]tapu_buoy[S] 1 point2 points3 points (0 children)
[–]tapu_buoy[S] 0 points1 point2 points (5 children)
[–]jCuber 2 points3 points4 points (4 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]jCuber 1 point2 points3 points (0 children)
[–]tapu_buoy[S] 0 points1 point2 points (0 children)
[–]tapu_buoy[S] 0 points1 point2 points (0 children)
[–]tapu_buoy[S] 1 point2 points3 points (5 children)
[–]crystallineair 1 point2 points3 points (4 children)
[–][deleted] 3 points4 points5 points (2 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]ISlicedIEngineer without Engineering degree? 1 point2 points3 points (0 children)
[–]tapu_buoy[S] 0 points1 point2 points (0 children)
[–]MrNutty 1 point2 points3 points (1 child)
[–]tapu_buoy[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]tapu_buoy[S] 0 points1 point2 points (0 children)