javascript - Pass object by reference to a returned function -
validations = [] isempty = (string) -> string '' or string undefined or string == null createvalidation = (scopevariable, expected, responsetext, inverse) -> if inverse == undefined inverse = false if !inverse returningvalidation = -> if scopevariable isnt expected $scope.response.text = responsetext $scope.response.class = 'text-danger' return false true else returningvalidation = -> if scopevariable expected $scope.response.text = responsetext $scope.response.class = 'text-danger' return false true returningvalidation validatecredentials = -> validated = true validations.map (validate) -> if !validate() validated = false validated $scope.register = -> if validatecredentials() #account.register $scope.f