বহিরাগত ফাংশন কলের জন্য রিটার্ন কীওয়ার্ড ব্যবহার করুন। নিম্নলিখিত কোড -
উদাহরণ
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()); উপরের প্রোগ্রামটি চালানোর জন্য, আপনাকে নিম্নলিখিত কমান্ডটি ব্যবহার করতে হবে -
node fileName.js.
এখানে, আমার ফাইলের নাম demo198.js।
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেPS C:\Users\Amit\javascript-code> node demo198.js The result of divideMethod()=2 The result of subtractMethod()=500