Javascript - Function Function Redefine

Introduction

Consider the following function

function addSomeNumber(num){
    return num + 100;
}

function addSomeNumber(num) {
    return num + 200;
}

var result = addSomeNumber(100);    //300

In this example, the last function overwrites the previous one.

The following code shows what is going on:

var addSomeNumber = function (num){
    return num + 100;
};

addSomeNumber = function (num) {
    return num + 200;
};

var result = addSomeNumber(100);    //300

The variable addSomeNumber is being overwritten when the second function is created.