daPhyre/webgl-lessons — pull request #4 by greggman (2014-01-19 11:37:52+00:00)
Title: Stop putting properties on WebGLObjects

The problem with putting properties on WebGLObjects is your app
will crash if you ever decide to handle WebGLContextLost events.
The reason is all of the gl.createXXX functions will return null
and so code like this

var buffer = gl.createBuffer();
buffer.itemSize = 3;

Will crash because buffer will be null. The simplest solution
is to use JavaScript objects. So for example instead of

var buffer = gl.createBuffer();
buffer.itemSize = 3;
gl.bindBuffer(..., buffer);

We can change it to

var buffer = { id: gl.createBuffer(); };
buffer.itemSize = 3;
gl.bindBuffer(..., buffer.id);

That at least is future proof code.