Question

3 Quick questions about javascript 1) Operators at the same level of precedence associate(evaluate) from right...

3 Quick questions about javascript

1) Operators at the same level of precedence associate(evaluate) from right to left. true or false?

2) The body of a do/while loop is always executed atleast once. True or false?

3) The continue statement allows us to stop and exit the loop immediately. True or false?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Operators at the same level of precedence associate (evaluate) from right to left.

Answer: false

In general operator with the highest precedence is evaluated first. When parentheses are used the operations within the parentheses are evaluated first. If the operators are of same level of precedence such as addition and subtraction then the expression is evaluated from left to right.

Example: var a= i + j – k

In the above example + and – have the same precedence, hence first i + j is evaluated and then

(i + j) – k is evaluated.

2. The body of a do/while loop is always executed atleast once.

Answer: True

Unlike the while loop in the do/while loop the body of the loop is executed first and then checks the condition. Hence the body of do-while loop is always executed atleast once.

3. The continue statement allows us to stop and exit the loop immediately.

Answer: False

The continue statement breaks one iteration of the loop when a specified condition is encountered, and continues the loop with the next iteration.

Example:

Suppose i=0

While(i<5)

{

            if(i%2==0)

            {

                        continue;

            }

            document.write("hi ");

            i++;

}

In the above example the loop rum from i = 0 to 5, whenever i is even the loop breaks the current iteration and continues with the next iteration.

Hence the above will write hi hi (when i is 1,3), it does not write hi when i is 0,2,4

Add a comment
Know the answer?
Add Answer to:
3 Quick questions about javascript 1) Operators at the same level of precedence associate(evaluate) from right...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

    QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points    QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...

  • 1. Which of the folowing statements about glucokinase and hexokinase (that catalyze the same reaction) is...

    1. Which of the folowing statements about glucokinase and hexokinase (that catalyze the same reaction) is TRUE? A. Glucokinase has a higher capacity than hexokinase to convert glucose to glucose 6 phosphate B. Hexokinase is only active in the liver where it can utilize multiple hexoses C. While glucokinase requires ATP for its action, hexokinase requires GTP D. Glucokinase can act on multiple glucose-like sugars (such as galactose) E. Hexokinase has a higher Km and easily handles all the glucose...

  • CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c...

    CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a...

  • 1) Which of the following is NOT true about a Python variable? a) A Python variable...

    1) Which of the following is NOT true about a Python variable? a) A Python variable must have a value b) A Python variable can be deleted c) The lifetime of a Python variable is the whole duration of a program execution.   d) A Python variable can have the value None.        2) Given the code segment:        What is the result of executing the code segment? a) Syntax error b) Runtime error c) No error      d) Logic error 3) What...

  • These are my answere to the following questions: are they right? 1. B 2. T 3....

    These are my answere to the following questions: are they right? 1. B 2. T 3. T 4. T 5. F 6. T 7. A 8. D 9. E 10. B 11. B 12. A 13. A 14. D 15. C 16. D 17. T 18. C 19. T 20. T 21. T 22. A 23. T 24. D 25. B 26. A 27. A 28. A 29. T 30. C 31. D 32. A 33. T 34. F 35....

  • matlap Question 1 1. Consider the following Matlab program 5 - (2 < 3) & (C2...

    matlap Question 1 1. Consider the following Matlab program 5 - (2 < 3) & (C2 > 3) 1 (1 - 0)) What is the final value of s? A. True B. *1 CO D. false 2- Which expression tests whether variable x is between (but not the same as) the values 5 and 10 (a) 5 <x< 10 (b) 5 <= x <= 10 (c) 5 < X & X > 10 (d) x < 10 & 5 <...

  • Easy Javascript questions You can use window.history to retrieve the history object. Using the history object, what methods can you call to navigate backwards and forward to web pages that have been...

    Easy Javascript questions You can use window.history to retrieve the history object. Using the history object, what methods can you call to navigate backwards and forward to web pages that have been visited recently? The answer is not in the book. See https://developer.mozilla.org/en-US/docs/Web/API/History. Think about the situation where the alert message displays “your reply was false.” Describe the type of person who would generate that output—someone who always tells the truth, someone who always lies, or some other type of...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • 1. Which of the following is true about a promissory estoppel? A) It is invoked in...

    1. Which of the following is true about a promissory estoppel? A) It is invoked in cases having incompetent parties. B) It permits a court to order enforcement of a contract that lacks consideration. C) It allows for a party to claim goods that were never paid for. D) It is invoked in cases that involve a promissory note. 2. Which of the following is true for a minor under the infancy doctrine? A) A minor is bound to the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT