Final Practice Technical Interview

These are some questions you may come across in an actual interview. You may not have gone over all of them during your time here, but use this practice as a time to learn and talk about what you don't yet understand.


Q

Write a function that will remove duplicates from an array. (Max time, 10 minutes)
Do not stress about time. Sudo code, ideas, and real code will all be considered.

function noDuplicates(arr){

}

noDuplicates([1,3,3,3,1,5,6,7,8,1]) //=> [1, 3, 5, 6, 7, 8]  
A

They can keep track of each unique item in a object.
They can push all items to a unique array and use indexOf to see if the item is in that array.


Q

What will be printed to the console and in what order?

const printName = function(name){  
  console.log(name)
  name = "Fin"
  console.log(name)
  return name
}

let name = "Suzan"

console.log(printName())

console.log(name)  
A

undefined
Fin
Fin
Suzan


Q

When would you use a Class Component over a Functional Component?

A

If your component has state or a lifecycle method(s), use a Class component. Otherwise, use a Functional component.


Q

What are keys in React and why are they important?

A

Keys are what help React keep track of what items have changed, been added, or been removed from a list.

render () {  
  return (
    <ul>
      {this.state.todoItems.map(({task, uuid}) => {
        return <li key={uid}>{task}</li>
      })}
    </ul>
  )
}

It’s important that each key be unique among siblings. The reconciliation and part of this reconciliation process is performing a diff of a new element tree with the most previous one. Keys make this process more efficient when dealing with lists because React can use the key on a child element to quickly know if an element is new or if it was just moved when comparing trees. And not only do keys make this process more efficient, but without keys, React can’t know which local state corresponds to which item on move.


Q

What is the difference between a controlled component and an uncontrolled component?

A

A controlled component is a component where React is in control and is the single source of truth for the form data. As you can see below, username doesn’t live in the DOM but instead lives in our component state. Whenever we want to update username, we call setState as we’re used to.

class ControlledForm extends Component {  
  state = {
    username: ''
  }
  updateUsername = (e) => {
    this.setState({
      username: e.target.value,
    })
  }
  handleSubmit = () => {}
  render () {
    return (
      <form onSubmit={this.handleSubmit}>
        <input
          type='text'
          value={this.state.username}
          onChange={this.updateUsername} />
        <button type='submit'>Submit</button>
      </form>
    )
  }
}

An uncontrolled component is where your form data is handled by the DOM, instead of inside your React component.


Q

What is Babel

A

Babel converts your ES6 code into ES5 so that browsers can read it.


Q

What are some new features in ES6?

This question should be open ended. Take some time with it.

If a the interviewee is floundering, give them prompts like:

  • How are functions different?
    • What else can you do for arguments?
    • Anything special you can do if the function has one line, and that one line is a return?
  • What are some cool things you can do with objects?
    • What if the property of the object is the same as the value?
    • What if you want to extract some properties from an object?
  • What are some cool things you can do with arrays?
    • If you need the items in an array, how can you get them?
    • What if you would like to assign variables to the first few items of an array?
  • How can we restrict our variable naming to help us avoid bugs?
    • How can we define a variable that we expect to change, but that we don't want redefined?
    • How can we define a variable that we do not expect to change?
  • Any cool things we can do with strings?
  • How is working with modules easier?
  • Do you know what object oriented programming is? How can we write constructor functions in ES6?
A

https://coursework.vschool.io/es6-basics/
https://coursework.vschool.io/classes/


Q

Explain the "same-origin policy," what it is and why it exists

A

A web browser permits scripts contained in a first web page to access data in a second web page, but only if both web pages have the same origin. Like, google.com or localhost:3000


Q

Explain what CORS is, how it works, and what purpose it serves

A

Uses HTTP headers to let a another origin access selected resources from a server on a different origin than the site currently in use.


Q

Explain what JSONP is, how it works, and what purpose it serves

A

JSONP is a method for sending JSON data without worrying about cross-domain issues.
JSONP does not use the XMLHttpRequest object.
JSONP uses the <script> tag instead.

Many APIs enable you to use JSONP because you're not able to do damage like you would be able to with the XMLHttpRequest object.


Q

Explain the idea behind token authentication. How is it different from session
authentication?

A

Is session authentication, the server takes the token and knows what user is requesting data, and makes sure the user is authorized to do that.

I token authentication, the server just verifies wether or not the token is valid.


Q

What is a JavaScript web token?

A

A standard way of creating a token that can store hashed information and prove authentication.

https://jwt.io/introduction/


Q

What purpose does Mongoose serve?

A

Mongoose helps us build models for our mongo database. Helps verify it's the structure of data we want, and helps us save and retrieve the data we want from the database.


Q

Explain what Node.js is

A

A backend JavaScript engine.


Q

What is MVC? Which part of MVC is React? How does Redux fit into it?

A

Model View Controller. The Model is the data, The View is what the user sees, and the Controller is the link between the two.


Q

How would you save JSON data in localstorage?

A

localStorage.<whatever> = data or
localStorage.set("whatever", data)


Q

What is the difference between == and === ?

A

Type checking only


Q

What is function hoisting?

A

With a function declaration, JavaScript will hoist the function to the top of the file, so that even if it's called before it's declared, JavaScript still knows what it is.

vs

Function expressions will need to be written before they're called.


Q

What is the difference between a callback and promise?

A

Promises happen asynchronously


Q

What does let scope your variable to?

A

The nearest curly brackets.


Q

What is an interpreted language? How does it compare to a compiled language?

A

Interpreted languages are compiled on the fly. Compiled languages are transformed to machine code and then ran.


Q

What is the difference between a language that is dynamically typed versus statically typed languages.

A

A statically typed language makes you explicitly state what type of data a variable will be equal to. A dynamically typed language let's you do stuff willy nilly.


Q

What does "immutable" mean?

A

It means "unchangeable". Simple/primitive data types are considered "immutable", like Strings, Numbers, Booleans. Mutable data types includes Arrays and Objects, where you can change something in the array without the computer having to relocate the array to a different place in memory.


Q

Explain the general concept of time complexity and Big-O.

A

This is how efficient your code is. For loops, nested for loops, etc are going to slow your code down. Possibly exponentially.

for loop -> 0(n)
nested for loop -> 0(n^2)