1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nastasia [14]
3 years ago
12

Assume the following JavaScript program was interpreted using staticscoping rules. What value of x is displayed in function sub1

? Under dynamic-scoping rules, what value of x is displayed in function sub1? var x; function sub1() { document.write("x = " + x + ""); } function sub2() { var x; x = 10; sub1(); }x = 5; sub2();
Computers and Technology
1 answer:
Annette [7]3 years ago
7 0

Answer:

Static scoping: x is 5

Dynamic scoping : x is 10.

Explanation:

Static scoping :

In static scoping the variable of a function take the value within the function.

If there is no values exist within the function then take the global value of the variable.

var x // No value is assigned to x so it check global value of x

function sub1() {

   document.write(“x = “ + x + “”); // So it print x = 5

}

function sub2() {

   var x;

   x = 10;

   sub1();

}

x = 5; // It is the global value of x

sub2();

Static scoping: x is 5

Dynamic scoping :

In Dynamic scoping the variable of a function take the value all the calling function ends.

If the global value is the last assigned value of a variable then it take that value.

If there exist some other function after global variable value if that function contain the variable with some assigned value variable take that value.

var x

function sub1() {

   document.write(“x = “ + x + “”);

}

x = 5; // At this point x value is 5 and check there exist a function

sub2(); // So now call this function

function sub2() {

   var x;

   x = 10; // The value of x = 5 is replaced with x = 10

   sub1();

}

Dynamic scoping : x is 10.

You might be interested in
A termination condition in a loop is analogous to________in a recursive method.
Varvara68 [4.7K]

Answer:

b) iteration.

Explanation:

There are various algorithms which are used in computer programming. Iteration is also a type of algorithm which is used to create loops. The instructions are inserted once and then these instructions are repeated to create a loop function.

8 0
3 years ago
You are a cleared employee. You discovered fraud and waste of money related to a classified program within your agency. If you r
Irina-Kira [14]

Answer:

A. True.

Explanation:

In this scenario, you are a cleared employee. You discovered fraud and waste of money related to a classified program within your agency. If you report this fraud and waste through appropriate channels, you may receive protection under the Presidential Policy Directive 19 (PPD-19): Protecting Whistleblowers with Access to Classified Information.

In USA, the Presidential Policy Directive 19 (PPD-19) which was signed by President Barack Obama in October 2012, is an executive order designed to provide significant protection for an employee who have access to classified informations such as fraud, waste of money and abuse or prohibiting any form of retaliation against this cleared employee.

3 0
3 years ago
TQ Automation<br> What is Robotic Process Automation (RPA)?
tamaranim1 [39]

Answer:

RPA or Robotic Process Automation allows organizations to automate tasks which human beings were doing across any applications and systems. The purpose of RPA is to transfer the execution of the process from humans to robots.

5 0
1 year ago
Is windows 7 professional faster than home premium?
Olin [163]
Widows 7 is no longer supported for anti virus, I recommend a windows 10 license
8 0
2 years ago
What is the output of the following code? (Please indent thestatement correctly first.)
goldenfox [79]

Answer:

no output, it does not print any thing

Explanation:

if-else statement is used to execute the statement after checking the condition if the condition is true, it allows the program to execute the statement otherwise not.

in the code, define the variable with values x = 9, y = 8 and z = 7.

Then, if the statement checks the condition 9 > 9, the condition is false.

So, the program terminates the if statement and executes the next statement but there is no next statement.

the other if-else statement is within the if condition which already terminates.

Therefore, there is no output.

7 0
3 years ago
Other questions:
  • A smart refrigerator can use what to detect when you are running low on milk, and then send a reminder to you on a wireless.
    8·1 answer
  • A restaurant has a case type that allows customer to book the dining room for events. Customers provide basic information includ
    7·1 answer
  • When someone registers a domain name that is a company's trademark, hoping to resell it to the company at an exorbitant profit,
    14·2 answers
  • Importance of Computer in the world​
    12·2 answers
  • Write a Twitter class that sets the Twitter user first (who is to be followed) and lets the client add up to 5 followers, which
    10·1 answer
  • Using the Vigenere cipher, does the length of the key matter?
    8·1 answer
  • The federal government is the largest employer of cybersecurity professionals true or false
    5·1 answer
  • Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whol
    12·1 answer
  • I need help pls help me
    8·1 answer
  • Is permanent software programmed into read-only memory.<br> Firmware<br> JavaScript<br> PHP<br> o
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!