0
self.scope.savesectioneditmain = [self.scope.savesection2details,
                                  self.scope.editsection2,
                                  self.scope.savesection1details,
                                  self.scope.editsection1];

Based on above codes, I want to check all array value equal to true value.

if($.inArray(true, self.scope.savesectioneditmain) == 0)

I have tried $inArray, but $inArray checks only one condition, but I want to check all array value should be equal to true.

2
  • What property in array do you want to check actually? Is it your array contains some object? or some string? I've been confusing. Commented Jan 2, 2017 at 11:22
  • string true or false,My array contain true or false. Commented Jan 2, 2017 at 11:28

1 Answer 1

1

You can use Array.prototype.every()

The every() method tests whether all elements in the array pass the test implemented by the provided function.

if(self.scope.savesectioneditmain.every(x => x == true)){
   //All elements are true
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.