JavaScript Screening Questions Flashcards

1
Q

What do you like about JavaScript?

A

Being able to learn a client side language that can also be used on the server side through node.js helps eliminate the need for learning multiple languages when starting to code. Syntactically, JavaScript also reads very close to English, which helps make it an accessible language to learn.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why do we want our code to be DRY?

A

DRY or “Don’t Repeat Yourself” is a principle of software development that states “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”. By adhering to this principle, we will avoid having to make changes in multiple places in our code base when one piece of code needs to be changed. This also applies to databases and documentation as well.

Keeping code DRY also has benefits in readability and performance. When each piece of code is written with the DRY principle in mind, developers will be more conscious of naming conventions and the role each function will play that they introduce to the codebase which results in better readability. Performance wise, avoiding unnecessary duplication of code will result in less weight that an app is carrying.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the steps to creating good user stories?

A

It’s important to clearly define the who, what and why of the story. The who is in reference to what type of user this story is for. The what is the functionality that we want to take place. The why explains the goal of the what - the user experience we’re seeking. After outlining the above we can add acceptance criteria which will help determine if the code written actually achieves all the desired goals.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of a JavaScript Class in OOP?

A

Classes give us the ability to define a template that can be used to create an object representation of something in our code that will be reusable and easier to interact with. These classes serve as a place to link the state and behavior of an object that is representing something in our codebase. In regards to OOP this gives us a way to build our code in encapsulated objects with single responsibilities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you define a class in JavaScript?

A

A Class can be defined through a class declaration. A class declaration will use the class keyword and the name of the class you are defining.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is scope?

A

Encapsulation is the bundling of data and functions that act on that data in such a way that direct access to that data is restricted from the outside. It’s an important concept to ensure that certain properties will not be accessible by public means and can only be interacted with through public functions that the developer has made available. If we were to create a User class that stores a social security number as an instance variable, we would want to ensure that it is not publicly available and only through certain functions that we have defined is it accessible for our program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the this keyword in JavaScript?

A

The this keyword can be used to access the current instance of an object from within a class or function similar to other languages. Most of the time this will be used to instance variables or methods from within a class. In JavaScript it can also be used to in the global context which will return the window or global object. It will also have a different value if using strict mode. In those instances this will remain undefined when entering a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is TDD and what are its benefits?

A

Test Driven Development is the process of converting software requirements into tests first and then using those tests to help write code second. The benefits include a higher code quality due to the test coverage and thought that has to go into the implementation. The maintenance of a codebase developed through TDD will require about half the time as one developed without TDD. This is due to a lower amount of bugs when the red, green, refactor pattern is followed in development. The constant refactoring also ensures a higher code quality.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are static methods?

A

All JavaScript objects have a prototype property that is a reference to another object. When a property is accessed on an object and if the property is not found on that object, the JavaScript engine looks at the object’s prototype, and the prototype’s prototype and so on, until it finds the property defined on one of the prototypes or until it reaches the end of the prototype chain. This behavior simulates classical inheritance, but it is really more of delegation than inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a Prototype method? (non-core)

A

JavaScript is a prototype-based language in which objects will have a prototype object that they can inherit methods and properties from. When you define a class and then create an instance of that class, you can see that it will have access to methods outside of what you explicitly defined within the class due to the prototypes it has inherited from.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  • Given an array of unsorted integers, return a sorted array with the integers list from lowest to highest. No .sort
A

Fancy Way:
var numArray = [140000, 104, 99]
numArray.sort((a, b) => a - b); // For ascending sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly