How to change variable from different js script

Hi there,
I am trying to make a variable accessible from driffentent js files. Therefore I have one file with the variable (like the Backend.js in the example). My problem is that I cannot actually change the values of the variables in the origin script.
For example using the hikr example: If I add a function to the backend that shows me a value:

function updateHike(id, name, location, distance, rating, comments) {
    return new Promise(function(resolve, reject) {
        setTimeout(function() {
            for (var i = 0; i < hikes.length; i++) {
                var hike = hikes[i];
                if (hike.id == id) {
                    hike.name = name;
                    hike.location = location;
                    hike.distance = distance;
                    hike.rating = rating;
                    hike.comments = comments;
                    break;
                }
            }

            resolve();
        }, 0);
    });
}

function showHike(){
    console.log(hikes[0].name)
}

module.exports = {
    getHikes: getHikes,
    updateHike: updateHike,

    showHike: showHike
};

If I now change this value in the app that calls a function in context.js, the value in the backend does not change. It even looks like I can uncomment the backend part in context.js and the app works just as fine as before.

function updateHike(id, name, location, distance, rating, comments) {
    for (var i = 0; i < hikes.length; i++) {
        var hike = hikes.getAt(i);
        if (hike.id == id) {
            hike.name = name;
            hike.location = location;
            hike.distance = distance;
            hike.rating = rating;
            hike.comments = comments;
            hikes.replaceAt(i, hike);
            break;
        }
    }
    Backend.updateHike(id, name, location, distance, rating, comments)
        .catch(function(error) {
            console.log("Couldn't update hike: " + id);
        });
}

I tried various methods, but without any success…
So the question is: How can I actually change the values in the vector in the backend.js, so I can access them from a third js script ?

Dear Hendrik,

If I got you right, same topic has been covered here: https://www.fusetools.com/community/forums/general/global_variables
and here:
https://www.fusetools.com/community/forums/howto_discussions/multiple_js_file_support

Hi Leonids,

I already read these threads and I actually get everthing working just fine, but I still do not unterstand where data are stored, since it looks like the data in backend are not effected at all.

@Hendrik: with the snippets you posted, it’s impossible to understand what you’ve done and exactly what does not work. We need complete, minimal reproductions to look at to suggest anything.

As a potential solution, start reading here and follow the links.

Hope this helps!