尝试仅获取一个数组

时间:2019-02-08 14:54:15

标签: javascript

我尝试仅获取一个具有不同元素的数组,但目前我具有不同的数组...

// ********* SOME CODE *********

var color = [];
var risk = []; 
var all_operational = [];

if(Operational.length == group.name.length){
    color = "green";
    risk = "Operational";
    all_operational.push(group.name);
    console.log(all_operational);
}

/* console.log(group.name) 
   OUTPUT: toto
           tata
           titi
           trtr

实际结果(console.log(all_operational):

  • ['toto'] ['tata'] ['titi'] ['trtr']

扩展结果:

  • ['toto','tata','titi','trtr']

1 个答案:

答案 0 :(得分:0)

看起来您的 @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "Offre") private Offer school; 是一个数组。如果应该这样,则可以使用group.name方法将all_operational展平。尝试.flat()