javaScript with statement

when you use the with statement, your code become shorter and easier to read.

the JavaScript - with statement lets you reference properties of an object without explicitly specifying the object itself.




example: look first the javaScript code.

       var    x  =   Math.cos( 5 * Math.pi)  +  math.sin( math.ln10 );

       var    y  =   math.tan( 14 * math.E)

when you use the with statement, your code becomes shorter and easier to read:


                         var  x   =  cos( 5 * pi )   +  sin( ln10 ) ;
                         var  y   =  tan( 14 * e );       

javaScript  this  keyword

the javascript this keyword refers to the current object, its can't modify.

the javascript this keyword can be used in object constructors to refer to the current object. 

in the following example, this refers to the newly created car object, and assigns values to its properties:

       function     car (color, model, power, price){
                          this.color   =  "red" ;
                          this.model  =  "bmw" ;
                          this.power =  "5000hp" ;
                          this.price   =  "$90000" ;

the javascript this keyword generally refers to the window object if used outside of the scope of any other object.

            this.alert("i am alert box");   
                                                       // this keyword  refer to the window object
            this.prompt("i am prompt box");    

inside an event handlers this references the current element. it can be used to get properties on modify the element.

        <button    onclick="alert(this.innerhtml)"> click me </button>

javaScript  void  operator

the void operator specifies an expression to be evaluated without returning a value.

the void operator evaluates its expression and returns undefined.

      void   expression;                //expression  is any valid javascript expression
 var  a, b, c, d;
       a = void (b=c=d=3343) ;
                    document.write("a is =="+a+"<br/>"+"b is =="+b+"<br/>");
                    document.write("c is =="+c+"<br/>"+"d is =="+d);
       a=(b=c=d=2245);                   // here  a value   is 3345
                    document.write('<br>'+"a is =="+a+"<br/>"+"b is =="+b+"<br/>");
                    document.write("c is =="+c+"<br/>"+"d is =="+d);                  

in this case, the value of a will be undefined.

When a browser follows a javascript: URI, it evaluates the code in the URI and then replaces the contents of the page with the returned value, unless the returned value is undefined. The void operator can be used to return undefined.

<a  href= "javascript : void(0);">click here to do nothing</a>
<a  href= "javascript : void('black');"> 

                                         click here for black bg</a>