svjr4q
Last Updated: February 14, 2019
·
576
· steveniseki

call and apply in JavaScript

The call method calls a function with a given <i>this</i> value and arguments provided individually.

The apply method calls a function with a given <I>this</I> value and arguments provided as an array.

var obj = {
    name: "obj"

    doSomething : function(x,y){
        var total =  x + y;
        alert(this.name + " = " + total);
    }
}

var foo = { name : "foo" };

var bar = { name : "bar" };

obj.doSomething.call(bar,3,6); // alerts bar = 9
obj.doSomething.apply(foo,[9,3]); // alerts foo = 12    

3 Responses
Add your response

31683

Super Su is one of the best app to root apps. SuperSU allows latest management of Super user access rights for all the apps on your device that need the root. It has great importance in the field of international security and it has great influence. It doesn’t contain any ads and great compatibility. SuperSu is a very amazing tool for Android developers and gamers.
https://supersuapp.com

29 days ago ·
31882

https://aptoideapp.co/aptoide-Android
Aptoide is a well-known alternative marketplace for Android devices where every user has and manages their stores and where all of the applications are free, as we may know at Google Play we can find some paid apps.

7 days ago ·