So you prefer:

    if ($scope.previousEnvironment !== null) {
        if ($scope.previousEnvironment.toString() !== environmentId.toString()) {
        }
    }