Call wrapper
as a constructor function.
var obj = new wrapper();
… so that this
is "an instance of wrapper" and not "the default object, window
".
Convention dictations that constructor functions are named with a capital letter, so all change wrapper
to Wrapper
throughout your program.
For further reading, see MDN on new
.