Why is the variable the same value for different instances?

1

I have the following code

File 1:

var fbuser_firstName;
var FB = require('fb');

var User = function (sender) {
    FB.api('/' + sender, 'get', {access_token: process.env.PAGE_ACCESS_TOKEN}, function (response) {
       User.initFbProfileInfo(response.first_name,response.locale);
     });
};

User.initFbProfileInfo = function (first_name,locale) {
   fbuser_firstName = first_name;
   fbuser_locale = locale;
};

User.prototype.getFb_firstName = function () {
    return fbuser_firstName;
};

module.exports = User;

File 2:

for(//quantidade){
    user_profile = new User();
      user_profile.getFb_firstName(sender)
}

where sender is a user id. the variable fbuser_firstName should be given the name of the current user. The problem is that when you have 2 users at the same time, the 2 are given the same name. For example if the user is speaking, userB will have the user nameA also. How can I solve this? (does it relate to the scope of the variable?)

    
asked by anonymous 09.05.2016 / 02:58

0 answers