বাইরের ফাংশন কলের জন্য return কীওয়ার্ড ব্যবহার করুন। নিচের কোডটি দেখুন −
উদাহরণ
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