The real speed in bitboards is created by precomputing the bitboards for every instance. This means that you already have the attacked squares for a rook on d4 and every other piece on every square. Even faster is to use magic bitboards, but that is too complicated for a forum. Although both are written in c, I suggest Crafty to understand bitboards better, and Stockfish for magic bitboards.
Note, most chess engines using bitboards keep the position in a bitboard. To get the occupied bitboard, they just or together all the piece bitboards. You're using an array for the position and trying to create these bitboards at each move generation, which is wasting more time than is saved from using the bitboard operations.
An alternative which is easier to understand with just a modest speed hit, I suggest a system described here. Chess move generation with bit boards in Javascript (In c, I timed the move generation in a 32,000 loop and it took only 32 ms. In Javascript it will be much slower, but it should be efficient enough.)