Q:

Hypothetical situation: front end replacing function

Is it possible that this situation could happen?  I ask this because someone told me that a function you declare can be overwritten on the client so they want to move the function and its functionality to the backend...
You declare a const function in javascript (inside a javascript file).  You render your page (using node.js/react.js/etc.) with that function on the client side.  Is it possible for the client to overwrite the function on the client side and therefore make your web application call some other function/ redirect you to some unwanted destination/url?

A:

Are you concerned about people with developer tools changing your code, or people inserting malicious scripts? 
It is hard to protect yourself from people who are diving in your code with developer tools, as these tools are quite sophisticated. Remember though that the changes they make are only applied on their behalf, just as long as they keep the tab open and do not refresh the page. This does not impose a danger to others. If you do not like people reading into your code, run a minify and obscure operation on it first before putting it on the server.
If you are concerned about malicious code, it is always a good idea to expose as little to the global namespace as possible. That is a simple measure you can take.
This example can be easily overwritten by a script:
var foo = 'bar';

function doSomething() {
    console.log(foo);
}

// evil script
doSomething = function () { 
   window.location = 'http://evil.com'
}

But by wrapping your code in an IEFE, you can make it harder to overwrite your functionalities from the outside:
(function() { // use an IEFE to wrap your code here
   var foo = 'bar';

   function doSomething() {
       console.log(foo);
   }
)();

// evil script
doSomething = function () {  // this function will not be called in your code
   window.location = 'http://evil.com'
}

