# JavaScript How to transform a matrix into array with one row transform matrix into vector matlab,transform matrix into dataframe r,

Consider a matrix `B= [[6,4,1,2], [5,3,9,7],[1,3,2,1]];`. B is a matrix with three rows and four columns. I want to treat it as an array or a vector, namely `B1=[6,4,1,2,5,3,9,7,1,3,2,1]`. Moreover, I want to have, for instance, that `B1[3]=2` - so it's a number, not a vector anymore. I wrote a simple function

``````function NewArray(Matrix){
var Temp = [];
var w = Matrix[0].length;
var h = Matrix.length;
for (i=0; i<w; i++){
for (j=0; j<h; j++){
Temp.push(Matrix[i][j]);
}
}
return Temp;
``````

}

It occours haowever, that it works only, when B is quadratic. What is wrong?

You could take the length of the nested array, instead of a predefined value in advance.

``````function newArray(matrix) {
var temp = [],
i, j, h, w;
for (i = 0, h = matrix.length; i < h; i++) {
for (j = 0, w = matrix[i].length; j < w; j++) {
temp.push(matrix[i][j]);
}
}
return temp;
}

console.log(newArray([[6, 4, 1, 2], [5, 3, 9, 7], [1, 3, 2, 1]]));``````
``.as-console-wrapper { max-height: 100% !important; top: 0; }``

You can use `apply` and `concat` methods in order to write a simplified solution.

``````B = [[6,4,1,2], [5,3,9,7],[1,3,2,1]]
B1 = [].concat.apply([], B);
console.log(B1);``````

## Setting iframe's window.external members through javascript

I have some code running in an html page that is calling a function that exists on window.external. The code works: SomeCode.js (lives in somePage.html): window.external['someFunction'](); However, ...

I have some code running in an html page that is calling a function that exists on window.external. The code works: SomeCode.js (lives in somePage.html): window.external['someFunction'](); However, ...

1. setting iframe height to match content height
2. setting iframe size
3. setting iframe width and height
4. setting iframe src in jquery
5. setting iframe height dynamically
6. setting iframe src in javascript
7. setting iframe height
8. setting iframe source with javascript
9. setting iframe content dynamically
10. setting iframe height to auto
11. setting iframe content
12. setting iframe width
13. setting iframe height dynamically using jquery
14. setting iframe border
15. setting iframe dimensions
16. setting iframe innerhtml
17. setting iframe height in css
18. iframe setting
19. iframe setting cookie
20. iframe setting in chrome

## How to group by an array and determine total count of rows using javascript

So in sql a common thing to do is a select statement with a group by and then a having count =1 or what have you. select bID from tableA groubBy bID having count(*) = 1 Essentially I am looking to ...

So in sql a common thing to do is a select statement with a group by and then a having count =1 or what have you. select bID from tableA groubBy bID having count(*) = 1 Essentially I am looking to ...

## AngularJS Error: [\$injector:nomod]

Strangely enough the module loads perfectly in Firefox. In Chrome only sometimes the module loads up (when refreshing on and off) and seems to be the only browser where the following console error ...

Strangely enough the module loads perfectly in Firefox. In Chrome only sometimes the module loads up (when refreshing on and off) and seems to be the only browser where the following console error ...

1. angularjs error injector modulerr
2. angularjs error injector unpr
3. angularjs error injector nomod
4. angularjs error injector
5. angularjs injector error unknown provider
6. angularjs uncaught error injector modulerr
7. angularjs ngmaterial injector error
8. angularjs factory injector error
9. angularjs bootstrap injector error
10. error injector modulerr
11. uncaught error \$ injector modulerr http errors angularjs org 1.6 9 /\$ injector modulerr

## A false Variable Doesn't Validate as false

I am having trouble understanding some weird behavior in my code and I am wondering if anyone can tell me what I am doing wrong? I have a Boolean variable isWaiting and it is saved as false in ...

I am having trouble understanding some weird behavior in my code and I am wondering if anyone can tell me what I am doing wrong? I have a Boolean variable isWaiting and it is saved as false in ...

1