Invocation

The body of a function is not executed until the function is invoked (or called). Function invocation looks much the same in most languages: the function’s name followed by a pair of parentheses. The parentheses might or might not have some arguments inside. To invoke the countToTen function, you simply use countToTen();. Give it a try in the console. You have invoked many a function already: console.log('Instruction 1'); is a function, as is phoneNumberPattern.exec(phoneNumber); (from prompt.js). These examples include arguments between the opening and closing parentheses (see the next section), but they are function invocations all the same.

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.