---
title: "JavaScript Functions: A tale of invocation; the second. · Appnovation"
url: "https://www.appnovation.com/insights/javascript-functions-tale-invocation-second"
description: "A deeper look at JavaScript functions and the different ways they're invoked, and how invocation affects 'this' and execution."
---

Article

# JavaScript Functions: A tale of invocation; the second.

[![](https://cdn.sanity.io/images/ey850001/production/36eb314260fb474cacc1b3a473d7e8402d997898-68x68.png?w=68&auto=format) Appno Blogger Appnovation Coop](/people/appno-blogger.md) Jan 14, 2013  
 3 min read 

![Appnovation Blog Default Header](https://cdn.sanity.io/images/ey850001/production/9efe1c26d9584ecfb3dfef5a63e698bf4567d305-1440x600.jpg?w=1400&auto=format) 

Taking a deeper look into functions. We will focus on invoking functions. The JavaScript code within the curly braces of a function is the body. The body of a function is not executed at the time of defining a function rather it is executed at the time of being invoked. Let's take a look at the ways a function can be invoked:

*   as functions
*   as methods
*   as constructors
*   indirectly through their call() and apply() methods

Invoke a function as a function:

When invoked by an invocation expression, a function is invoked as functions or as methods (described in a moment). An invocation expression is a function expression that evaluates to a function object followed by an open parenthesis, a comma-separated list of zero or more argument expressions, and a close parenthesis.

`var total = distance(0,0,2,1) + distance(2,1,3,5);`

In an invocation, each argument expression is evaluated, and the resulting values become the arguments to the function. These values are assigned to the parameters named in the function definition. In the body of the function, a reference to a parameter evaluates to the corresponding argument value.

With a method invocation, a method is a property of an object that evaluates to a function object.

`person = {`

`firstName: “John”,`

`lastName: “Doe”, fullName: function _get`

`FullName () { this.result = this.firstName + “ “ +`

`this.lastName;`

`}`

`};`

The above example shows a person object with a fullName method as a property of person. Our fullName() property returns the firstName and lastName concatenated from our person object.

With the method fullName() defined to the object person, it can be invoked like this:

`person.fullName(); // a method invocation to concatenate firstName and lastName of a person`

`object`

`person.result // => John Doe`

Methods and this keyword are imperative to object-oriented programming. Any function that is used as a method is effectively passed an implicit argument: the object through which it is invoked. Ideally, a method performs an operation on that object, and the method-invocation syntax is an elegant way of expressing such.

Invoke a function as a constructor:

If a function or method invocation is preceded by the keyword new, then it is a constructor invocation. Constructor invocations are different than regular function and method invocations, specifically their handling of arguments, invocation context, and return value.

`var o = new Object();`

A constructor invocation creates a new, empty object that inherits from the prototype property of the constructor. Constructor functions are intended to initialize objects and this newly created object is used as the invocation context, so the constructor function can refer to it with this keyword.

Indirect Invocation:

Like all JavaScript objects, functions have methods. Namely, but not limited to, call() and apply(). Both of which invoke a function indirectly. Both methods can invoke any function as a method of any object, even if it is not actually a method of that object. Both methods also allow you to specify the arguments for the invocation. The call() method uses its own argument list as arguments and the apply() method expects an array of values to be used as arguments. For more info on this subject, please see [Part One](/insights/javascript-functions-tale-invocation-second.md).

[![](https://cdn.sanity.io/images/ey850001/production/36eb314260fb474cacc1b3a473d7e8402d997898-68x68.png?w=68&auto=format) Appno Blogger Appnovation Coop · Appnovation](/people/appno-blogger.md) 

## Keep reading

[![What is Sovereign AI](https://cdn.sanity.io/images/ey850001/production/a5889abdd5e80376912546622e046e3fbef234b4-2496x1664.png?w=640&auto=format)](/insights/what-is-open-source-sovereign-ai.md)

 Article · 7 min AI 

### [What Is Open Source, Sovereign AI?](/insights/what-is-open-source-sovereign-ai.md)

Every company is encouraging more AI, and almost every AI bill is climbing. Sovereign AI is about two kinds of control: over your data and over your costs. Here's why open source sits at its foundation.

[Iain MacNeil](/people/iain-macneil.md) Article 

[![AI-first experience design](https://cdn.sanity.io/images/ey850001/production/8bbc2418e87924ef10f36115478a2e10d5bed95e-1584x624.jpg?w=640&auto=format)](/insights/how-build-ai-first-experience-without-throwing-out-everything-youve-already-built.md)

 Article · 6 min AI Sep 10, 2026 

### [How to Build an AI-First Experience Without Throwing Out Everything You've Already Built](/insights/how-build-ai-first-experience-without-throwing-out-everything-youve-already-built.md)

Users now expect a direct answer, not a list of links to click through. Here's how organizations can layer an AI-First experience onto their existing website or app, in weeks rather than years.

[Andrew Douglas](/people/andrew-douglas.md) Article 

[![What Becomes Possible When AI Can Read All the Data](https://cdn.sanity.io/images/ey850001/production/c28ab0bd26753421ee42937e13adc7a7f19b47f0-1296x510.jpg?w=640&auto=format)](/insights/what-becomes-possible-when-ai-can-read-all-data.md)

 Article · 4 min AI Sep 09, 2026 

### [What Becomes Possible When AI Can Read All the Data](/insights/what-becomes-possible-when-ai-can-read-all-data.md)

Most of the world's data has never been analyzed, only sampled. AI changes that. How AI-ready data platforms unlock questions no one could ask before.

[Appnovation](/people/appnovation.md) Article 

## Get the thinking,  
*before everyone else.*

One considered email a month. New essays, field notes from live engagements, and the occasional strong opinion. No noise.
