# Hack Reactor Week 5 Review

Monday morning of Week 5 we had an hour long review of our experience from Week 4. Since week 4 is considered the hardest week, there is concern from the instructors that we would be disappointed and frustrated. We all talked about our experiences and realized that we learned quite a bit during the week despite our frustrations.

Week 5 starts out with an introduction to authentication. Now that we have completed our first full-stack application, we need to be able to implement authentication to allow users to create an account and to login to the server.

There are many things to consider when implementing authentication on your server.

• How do I store user and password information securely
• What additional steps will the user need to take when interacting with the application
• What strategies do I need to employ to secure existing site functionality
• How often should the user need to enter their username and password

# Time Complexity Analysis in JavaScript

An algorithm is a self-contained step-by-step set of instructions to solve a problem. It takes time for these steps to run to completion. The time it takes for your algorithm to solve a problem is known as time complexity.

Here is the official definition of time complexity. The time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the string representing the input.

That sounds like a mouth full and you are probably trying to understand exactly what that means. In simple terms, time complexity is defined by the time and space required by a particular algorithm.

It is not unusual to find many different methods that you can use to solve a problem. The length of time it takes and the number of operations taken are used to determine how effective your algorithm is in solving the problem. Complexity helps programmers to understand, and therefore improve, the efficiency of our code.

The best programming solutions in JavaScript utilize algorithms that provide the lowest time complexity possible.

# Hack Reactor Week 4 Review

Week 4 is considered the hardest week at Hack Reactor. In fact it is so challenging that at the end of Week 3 we had a special meeting to discuss what to expect for this week.

When the instructors tell you point blank that it is not uncommon for people to feel completely lost and totally confused then you wonder what is in store for you.

Week 4 is our first foray into building complete full-stack applications. During this week we will learn about NodeJS and handling asynchronous event loops. Mid week we transitioned into learning about data storage structures and server side concepts. The end of the week we jumped head first into databases.

# The Difference Between .call and .apply in JavaScript

JavaScript has functions. When you execute that function then the contents of the function are performed. The easiest way to execute a function is to call it like getName().

JavaScript also provides two other methods to invoke that function:

• getName.apply()
• getName.call()

You might ask what is the difference between the two? Does one provide better performance than the other? Is one better to use than the other?

The best way to understand the difference between the two is to examine the pseudo syntax for each.

```function.apply(thisArg, [argsArray]);
function.call(thisArg[, arg1[, arg2[, ...]]]);
```

# Understanding Closure in JavaScript

A closure is a function object that retains ongoing access to the variables of the context it was created in (even after the outer function calls it was created within have returned).

In other words, the function defined in the closure 'remembers' the environment in which it was created.

Let me give you an example:

```function getName()
var firstName = 'Jennifer';
function showName()