with : With : Statement JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Statement » With »

 

with









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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Statement
» With