this inside function javascript code example

Example 1: javascript this

// In web browsers, the window object is also the global object:
console.log(this === window); // true

a = 37;
console.log(window.a); // 37

this.b = "MDN";
console.log(window.b)  // "MDN"
console.log(b)         // "MDN"

Example 2: 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