Can’t detect the object

Asked

Viewed 37 times

0

I made an API script, in this script has some basic functions well used. I am currently working on editing Intervalsapi:

var interval = {

    intervals: { },

    create: function(name, func, interval) {
        if(this.intervals[name] != null){
            c.e("[IntervalAPI] Interval with name `"+name+"` already exists!");
        }
        else {
            this.intervals[name] = setInterval(func, interval);
            c.t("IntervalAPI", "Interval `"+name+"` created. Total Intervals: " + _.size(this.intervals));
        }
    },

    delete: function(name){
        if(this.intervals[name] != null){
            clearInterval(this.intervals[name]);
            c.ti("IntervalAPI", "Interval `"+name+"` removed.");
        }
        else {
            c.te("IntervalAPI", "Interval `"+name+"` not found.");
        }
    },

    clear: function(){
        _.each(this.intervals, function(v,k){
            clearInterval(v);
            c.t("IntervalAPI", "Interval `"+k+"` removed.");
        });
    }
};

When I run interval.create("teste", function(){ c.l("Is a Console.Log")}, 1000); appears the message normally that interval has been added. However when I try to remove interval.delete("teste"); says undefined and consequently the message

[Intervalapi] Interval teste not found.

in interval.intervals has the object { test: ... } and is not returning.

  • If this is exactly how you put it, you will create "test" and try to delete "test", with a different name

  • no :) everything is the same,

  • I was wrong when it came to typing.

  • 1

    @sysWOW32 tried to reproduce the problem, but could not.: https://jsfiddle.net/8oam9my1/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.