Calling a Function with Arguments

Write the reason you're deleting this FAQ

Calling a Function with Arguments

Can someone please explain how to call a function with arguments? Or, post a video of how this is done?


Please login or sign up to leave a comment

What do you exactly mean? If there is a function with parameters within ( ), you would simply go with funcName(parameter1, paramter2) and so on...


var func1 = function(name,lastName) {

alert("You have entered " + name + " " + lastName);

// You call the function this way

func1("Captain","Bosnia"); // Alerts You have entered Captain Bosnia

If you are defining the arguments inside, then you can do it this way.

var func2 = function(name, lastName) { = "Captain";
this.lastName = "Bosnia";
alert( + " " + this.lastName);

func2(); // Logs Captain Bosnia

However, if you are creating a function that contains stuff that cannot be accessed from outside, then you must create a public method in order to access it.

Are you sure you want to delete this post?