Question:What do you mean by “with” statements? Write it’s syntax. 

Answer 
With statement:


1. JavaScript’s with statement was intended to provide a shorthand for writing recurring accesses to objects.
2. Instead of having to list all of the properties of an object by repeating the basic object, we can state the bulk of the object in a with statement and then the properties within the context of the with statment.

Syntax:
with (object){
  statement
}

Example:
var a, x, y;
var r = 10;
with (Math) {
  a = PI * r * r;
  x = r * cos(PI);
  y = r * sin(PI / 2);
}
 


Deprecated: html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated in D:\webserver\www\vcampusbd_com_https\answers\column_answer_two.php on line 128
+ Report
Total Preview: 1042
What do you mean by “with” statements? Write it’s syntax.
Copyright © 2024. Powered by Intellect Software Ltd