Just wrap in parenthesis and call the function.
let theNumber2 = (() => { return 2; })();
console.log(theNumber2);
Answer from Nina Scholz on Stack OverflowMDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Functions › Arrow_functions
Arrow function expressions - JavaScript - MDN Web Docs
February 21, 2026 - An arrow function expression is ... and deliberate limitations in usage: Arrow functions don't have their own bindings to this, arguments, or super, and should not be used as methods. Arrow functions cannot be used as constructors. Calling them with new throws a ...
W3Schools
w3schools.com › js › js_arrow_function.asp
JavaScript Arrow Functions
In this case, this does not refer to the person object. ... Parentheses are required for zero or multiple parameters. Arrow functions do not bind this. Arrow functions are not hoisted. You have now learned the most important concepts about JavaScript functions.
Videos
05:56
#26 Arrow function in JavaScript - YouTube
12:43
Callback and arrow function introduction in array - YouTube
20:23
JS Arrow Functions: Everything You Need to Know - YouTube
09:32
JavaScript ES6 Arrow Functions Tutorial - YouTube
08:06
#15 JavaScript Arrow Functions | JavaScript for Beginners - YouTube
Programiz
programiz.com › javascript › arrow-function
JavaScript Arrow Function
JavaScript arrow functions are a concise syntax for writing function expressions. Here's a quick example of the arrow function. You can read the rest of the tutorial for more. // an arrow function to add two numbers const addNumbers = (a, b) => a + b; // call the function with two numbers const result = addNumbers(5, 3); console.log(result); // Output: 8 · In this example, addNumbers() is an arrow function that takes two parameters, a and b, and returns their sum.
GeeksforGeeks
geeksforgeeks.org › arrow-functions-in-javascript
Arrow functions in JavaScript | GeeksforGeeks
Use arrow functions for callbacks and array methods to improve readability. Avoid arrow functions in object methods if this needs to refer to the object itself. Prefer arrow functions in functional programming patterns for their concise syntax. Use rest parameters for variadic functions when arguments are needed. ... JavaScript ...
Published May 17, 2025
DigitalOcean
digitalocean.com › community › tutorials › understanding-arrow-functions-in-javascript
Understanding Arrow Functions in JavaScript | DigitalOcean
August 28, 2021 - Like traditional function expressions, arrow functions are not hoisted, and so you cannot call them before you declare them. They are also always anonymous—there is no way to name an arrow function.
TutorialsPoint
tutorialspoint.com › javascript › javascript_arrow_functions.htm
JavaScript - Arrow Functions
In the below code, we use the ternary operator, and based on the boolean value of the 'isMul' variable, we assign the arrow function expression to the 'func' variable. After that, we use the 'func' variable to call the arrow function stored in that.
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript arrow functions
A Gentle Introduction to JavaScript Arrow Function
November 14, 2024 - function show() { return (x) => x + arguments[0]; } let display = show(10, 20); let result = display(5); console.log(result); // 15Code language: JavaScript (javascript) The arrow function inside the show() function references the arguments object.
SitePoint
sitepoint.com › blog › javascript › arrow functions in javascript: how to use fat & concise syntax
Arrow Functions in JavaScript: Fat & Concise Syntax — SitePoint
November 15, 2024 - Arrow functions aren’t just a fancy new way of writing functions in JavaScript. They have their own limitations, which means there are cases when you don’t want to use one. The click handler in the previous demo is a case in point, but it’s not the only one. Let’s examine a few more. Arrow functions don’t work well as methods on objects. Here’s an example. Consider this netflixSeries object, which has some properties and a couple of methods. Calling console.log(netflixSeries.getLikes()) should print a message with the current number of likes, and calling console.log(netflixSeries.addLike()) should increase the number of likes by one and then print the new value with a thankyou message on the console:
YouTube
youtube.com › watch
#46 How to use Arrow Functions | JavaScript Full Tutorial - YouTube
In this lesson we'll learn all about Arrow Functions, arrow functions are a new modern way of writing functions, they provide a cleaner and more concise synt...
Published November 29, 2021
Top answer 1 of 3
3
It should be working. Check this: working functions
'use strict';
const function1 = async (token) => {
console.log(token);
};
const function2 = async(token, permission) => {
// I want to call function1 here like
function1(token);
};
function2('apple','ball');
2 of 3
0
I think the problem is the way you importing/exporting the functions: I changed your code a little and it works:
const function1 = async (token) => {
console.log(token)
};
const function2 = async (token) => {
// I want to call function1 here like
//console.log(token)
function1(token);
};
export const f= { function1, function2 }
and code that using the function:
import {f} from './funcs.ts'
f.function2('ooo')
look at this plunk
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript arrow functions
JavaScript Arrow Functions
November 14, 2024 - function show() { return (x) => x + arguments[0]; } let display = show(10, 20); let result = display(5); console.log(result); // 15Code language: JavaScript (javascript) The arrow function inside the show() function references the arguments object.
YouTube
youtube.com › watch
Learn JavaScript ARROW FUNCTIONS in 8 minutes! 🎯 - YouTube
// arrow functions = a concise way to write function expressions// good for simple functions that you use only once00:00:00 i...
Published November 13, 2023
LogRocket
blog.logrocket.com › home › how and when to use javascript arrow functions
How and when to use JavaScript arrow functions - LogRocket Blog
February 17, 2025 - Since the arrival of the ES2015 standard, JavaScript programmers have had arrow functions in their toolbox. Their main strength is the abbreviated syntax; you don’t need the function keyword, and with implicit return you don’t need a return statement. The lack of a this binding can cause confusion, but is also handy when you want to preserve the enclosing this value to another function when passed as a callback.
TOOLSQA
toolsqa.com › javascript › javascript-arrow-function
What is JavaSCript Arrow function and How to use it with examples?
It should show the following output: As is evident from the above screenshot, the same task of the map, reduce and filter can be achieved with a much cleaner syntax with the help of "Arrow" functions. We know that the asynchronous callbacks or promises contain a great deal of "function" and "return" keywords. When using promises, we generally use function expressions to chain these calls as follows: <html> <body> Demonstrating promise consumer using .then() method in javascript:</br> <script type="text/javascript"> function createDivAndAppendText(divID, text) { const outPutElem = document.crea