with : With « Statement « JavaScript Tutorial






Syntax

with(object){
      code;
    }

The with statement takes an object and refers to all of the properties, methods, and events of that object without directly referencing the object itself.

<html>
    <script language="JavaScript">
    <!--
    var myNum = 25;

    var myE, mySin, mySqrt;

    with (Math) {
       myE = E;
       mySqrt = sqrt(myNum)
       document.writeln(mySqrt);
       mySin = sin(PI/myNum);
       document.write(mySin);
    }
    -->
    </script>
</html>








3.11.With
3.11.1.with
3.11.2.with statement