Q:

Undeclared variable receiving a function in a Angular service

I'm getting started with Angular JS and i'm working on tutorial i found on internet :
http://www.sitepoint.com/user-authenication-mean-stack/
In a service there are 3 undeclared variables receiving a function and i don't understand this syntax despite my researches.
code :
register = function(user) {
  return $http.post('/api/register', user).success(function(data){
    saveToken(data.token);
  });
};

The code for the whole service:
(function () {

  angular
    .module('meanApp') // service qui dépend de ce module ?
    .service('authentication', authentication);

  // $inject : To allow the minifiers to rename the function parameters and still be able to inject the right services, the function needs to be annotated with the $inject property. The $inject property is an array of service names to inject.
  // https://docs.angularjs.org/guide/di

  authentication.$inject = ['$http', '$window'];

  function authentication ($http, $window) {

    var saveToken = function (token) {
      $window.localStorage['mean-token'] = token;
    };

    var getToken = function () {
      return $window.localStorage['mean-token'];
    };

    var isLoggedIn = function() {
      var token = getToken();
      var payload;

      if(token){
        payload = token.split('.')[1];
        payload = $window.atob(payload); will decode a Base64 string
        payload = JSON.parse(payload);

        return payload.exp > Date.now() / 1000;
      } else {
        return false;
      }
    };

    var currentUser = function() {
      if(isLoggedIn()){
        var token = getToken();
        var payload = token.split('.')[1];
        payload = $window.atob(payload);
        payload = JSON.parse(payload);
        return {
          email : payload.email,
          name : payload.name
        };
      }
    };

    //An interface between the Angular app and the API, to call the login and register end-points and save the returned token. This will use the Angular $http service
    register = function(user) {
      return $http.post('/api/register', user).success(function(data){
        saveToken(data.token);
      });
    };

    login = function(user) {
      return $http.post('/api/login', user).success(function(data) {
        saveToken(data.token);
      });
    };

    logout = function() {
      $window.localStorage.removeItem('mean-token');
    };

    return {
      currentUser : currentUser,
      saveToken : saveToken,
      getToken : getToken,
      isLoggedIn : isLoggedIn,
      register : register,
      login : login,
      logout : logout
    };
  }

})();

Thank you for your explanations

A:

This code example is inconsistent with declaring its variables. It's considered best practice to use the var statement when declaring a variable, but when not running strict mode the var can be omitted. 
You generally should use 'use strict' at the top of your javascript file, so undeclared variables won't be permitted as the browser is running the JS in strict mode.
something like this:
(function () {
  'use strict';
  angular
    .module('meanApp') // service qui dépend de ce module ?
    .service('authentication', authentication);
[...]

