
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
JavaScript outsider function call and return the result
Use the return keyword for outsider function call. Following is the code −
Example
var substractMethod = function () { var firstValue =1000, thirdValue= 200; var divideMethod = function (){ var secondValue =500; console.log("The result of divideMethod()="+(firstValue/secondValue)); return (firstValue-secondValue); } return divideMethod; } var result = subtractMethod(); console.log("The result of substractMethod()="+result());
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo198.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo198.js The result of divideMethod()=2 The result of subtractMethod()=500
- Related Articles
- JavaScript Function Call
- How to call jQuery function with JavaScript function?
- Call a function with onclick() – JavaScript?
- How to call a Java function inside JavaScript Function?
- How to return the response from an asynchronous call in Javascript?
- How to call a function in JavaScript?
- How to delay a JavaScript function call using JavaScript?
- JavaScript display the result of a function as HTML?
- How to call a JavaScript function on click?
- How to use setInterval function call in JavaScript?
- How to call a JavaScript function from C++?
- How to call a JavaScript function in HTML?
- How to call a function that returns another function in JavaScript?
- Implementing Math function and return m^n in JavaScript
- Unconditional call and return instructions in 8085 Microprocessor

Advertisements