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
What engine component is shown in the above Figure?
astra-53 [7]

send attached file with it


5 0
3 years ago
Read 2 more answers
What can search the internet and select elements based on important words
Lana71 [14]

The item in question is known as a web search engine. These services will crawl websites and gather information about web pages to present to the searching user based on the search terms compared to the content of the webpage.

7 0
3 years ago
Describe what Carmen should do in the following scenario.
Fudgin [204]

Answer:

...................USB?

8 0
3 years ago
Read 2 more answers
Program _______ graphically present the detailed sequence of steps needed to solve a programming problem.
AlekseyPX

Program Pseudocode graphically present the detailed sequence of steps needed to solve a programming problem.

<h3>What are Pseudocode?</h3>

These are known to be a set of codes that a program has graphically depicted all of its sequence of steps that can be sued to handle a programming problem.

Note that Pseudocode is a form of artificial and man made informal language that is often used by programmers to create  algorithms.

Learn more about Program from

brainly.com/question/153827

#SPJ1

3 0
2 years ago
Television and movies are an important medium of communication. Perform online and offline research, and describe the history of
iren2701 [21]

Answer:

The American film industry, popularly called Hollywood, has played an important role as a platform for communication. It has influenced audiences the world over. The history of Hollywood begins in 1910 with the silent movie In Old California. The 1920s saw the arrival of movies with sound and music. In the 1940s, during and after World War II, movies were made on themes related to war. In the 1950s, Hollywood movies began to compete with television, as television entered American homes. Cutting to the 1990s, the use of animation in movies began to rise. The 2000s saw a continuation of this trend. Movies are now made using the most advanced technology and effects.

Hollywood movies play an important role in the communication process. It can bridge the gap between different communities, cultures, races, and nations. For example, the movie The Help highlighted the gross discrimination the Blacks suffered during the 1960s. Movies have also played a great role in building harmony between cultures. For example, the movie Eat, Pray, Love explores Eastern cultures. Animated movies are enjoyed by movie lovers of all ages, and often end with a good message.

Explanation:

PLATO

7 0
2 years ago
Other questions:
  • A byte in memory is identified by a unique number called its
    8·1 answer
  • If a surface is. it is exactly vertical
    11·1 answer
  • Which statement best represents the denotation for the word “woman”? A woman is an adult human female. Both man and woman are re
    11·2 answers
  • Software that was designed to serve the needs of a specific company or organization is called:
    5·1 answer
  • Why is self-esteem important in self-representation
    7·1 answer
  • In a non-formatted/standard template, if the number 25 is converted to text format, the
    14·1 answer
  • What does Data storage enable a browser to do
    5·1 answer
  • The electric company gives a discount on electricity based upon usage. The normal rate is $.60 per Kilowatt Hour (KWH). If the n
    7·1 answer
  • Discuss how the accessibility of television has changed over time
    7·1 answer
  • what impact of information communication technology have on the environment about electronic waste, use of electricity?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!