Consider the following JavaScript skeletal program:// The main programvar x;function sub1() {var x;function sub2() {. . .}}function sub3() {. . .}Assume that the execution of this program is in the following unit order:main calls sub1sub1 calls sub2sub2 calls sub3a. Assuming static scoping, in the following, which declarationof x is the correct one for a reference to x?i. sub1ii. sub2iii. sub3b. Repeat part a, but assume dynamic scoping.