JavaScript - Generate random pixels on HTML5 canvas

I want to create a random generated image (random colors), like this one. But, I want to do it in javascript, but for some reason I am getting black screen.

Here is my code:

var g=document . createElement( 'canvas').getContext('2d');
g.canvas.width=g.canvas.height = 800;
g.imgd = g.getImageData(0, 0, 800, 800); =;, index) => (index & 3) < 3 && ([index] = Math.random()));
g.putImageData(g.imgd, 0, 0);


And i am getting black screen, and on some websites it is white screen. So what is what not working in my script? My english is not very good, but can someone explain what is wrong, my code dont'esnt working.

I also tried different dimensions of canvas and I dont see any errors so what is wrong?