mardi 20 décembre 2016

How to write an if-statement?

I do get some errors because something are not defined yet only when I manual write an local notification it is about the following:

Uncaught TypeError: Cannot read property '1' of undefined

Where this refers to this:

    title = info.data.test()[1];
    message = info.data.test()[2];

What I did is this:

 if (!Array.prototype.test){
    Array.prototype.test = function(){
        return this[this.length - 1];
    };
};

if(info.data.test()[1] || info.data.test()[2]){
    console.log('check 1,2');
    title = info.data.test()[1];
    message = info.data.test()[2];
}else {
    null
}

But still throws me that error and on this the same:

Uncaught TypeError: Cannot read property 'top' of undefined

if($('.last-notification')){

    console.log('check lasrt-notification');
    $('html, body').animate({
        scrollTop: $('.last-notification').parent('div').offset().top - 33
    }, 800);
   }

Aucun commentaire:

Enregistrer un commentaire