javascript use function that inside a function code example

Example 1: function inside function javascript

function getFullName() {
	return getName() + ' ' + getLastName();
  	function getName() {
    	return 'William';
    }
  	function getLastName() {
    	return 'Wallace';
    }
}

console.log(getFullName());
//William Wallace
console.log(typeof getFullName);
//function
console.log(typeof getName);
//undefined
console.log(typeof getLastName);
//undefined

Example 2: running a function in a function javascript

function runFunction() {
  myFunction();
}

function myFunction() {
  alert("runFunction made me run");
}

runFunction();

Tags:

Java Example