JavaScript JavaScript merge multiple Boolean arrays and the OR || operator javascript merge multiple arrays,javascript merge multiple objects,javascript merge

I want to merge this array using or || operator

[[true,false,false],[false,false,false],[false,false,true]]

so that the output is

[true,false,true]

is this possible with map or reduce or similar?

Edit: Sorry for the unclear question - yes it was to vertically merge all sub arrays together. So the following input:

[[true,false,false],[false,false,false],[false,false,true],[false,false,true]]

would produce the same output:

[true,false,true]
Answer:1

You could reduce the arrays with mapping the same index values.

var array = [[true, false, false], [false, false, false], [false, false, true]],
    result = array.reduce((a, b) => a.map((c, i) => b[i] || c));

console.log(result);
Answer:2

You don't really need the || when you use some:

var array = [[true, false, false], [false, false, false], [false, false, true]];

var result = array[0].map( (_, i) => array.some(a => a[i]));

console.log(result);
Answer:3

I understand the word self has no special meaning in javascript. Below code, while if one writes as var Life = function( ....), it's clear but author decide to do var _ = self.Life = function(...). ...

I understand the word self has no special meaning in javascript. Below code, while if one writes as var Life = function( ....), it's clear but author decide to do var _ = self.Life = function(...). ...

I have this JSON file on my server: {"1504929411112":{"name":"user1","score":"10"},"1504929416574":{"name":"2nduser","score":"14"},"1504929754610":{"name":"usr3","score":"99"},"1504929762722":{"name":...

I have this JSON file on my server: {"1504929411112":{"name":"user1","score":"10"},"1504929416574":{"name":"2nduser","score":"14"},"1504929754610":{"name":"usr3","score":"99"},"1504929762722":{"name":...

  1. node sort json array
  2. node sort json
  3. node json sort keys
  4. node js sort json array
  5. node js sort json by value
  6. node js sort json object
  7. node js sort json
  8. node js sort json by date
  9. node js sort json alphabetically
  10. node.js sort json array

Angular cancels a $http call when the timeout promise gets resolved or when the timeout if passed as integer exceeds the specified time. I created an implementation in my projects that cancels ...

Angular cancels a $http call when the timeout promise gets resolved or when the timeout if passed as integer exceeds the specified time. I created an implementation in my projects that cancels ...

  1. what happens when session timeout in asp.net
  2. what happens when session timeout in java
  3. what happens after session timeout
  4. what happens in a timeout

I have a function: renderConversations(){ let conversationContent = this.state.conversationArray.map((convObj, i) => { return <View key={i} style={[globalStyle.conversationContainer,...

I have a function: renderConversations(){ let conversationContent = this.state.conversationArray.map((convObj, i) => { return <View key={i} style={[globalStyle.conversationContainer,...

  1. iterate over array javascript
  2. iterate over array python
  3. iterate over array java
  4. iterate over array bash
  5. iterate over array golang
  6. iterate over array of objects javascript
  7. iterate over array ruby
  8. iterate over array c++
  9. iterate over array java 8
  10. iterate over array php
  11. iterate over array matlab
  12. iterate over array swift
  13. iterate over array typescript
  14. iterate over array react
  15. iterate over array perl
  16. iterate over array scala
  17. iterate over array jquery
  18. iterate over array rust
  19. iterate over array es6
  20. iterate over array powershell