I have an object that has a function that reads information into an array.
I call an instance of the object to open a file, it reads the information into RAWDATA:[]
.
I then call the function doSomething
however RAWDATA[1].length
is undefined
if this is not a syntactical error does this mean that a an event function such as below cannot permanently affect the objects variables?
var object{
RAWDATA:[],
openFile: function (event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function () {
var dataURL = reader.result;
console.log(dataURL);
this.RAWDATA = dataURL.split(",");
this.NEWDATA = this.RAWDATA[1];
alert("raw data length "+this.RAWDATA[1].length);
};
reader.readAsDataURL(input.files[0]);
},doSomething: function(){
console.log(this.RAWDATA[1].length);
alert("raw data length "+this.RAWDATA[1].length);
}