Void,d Typeof, New, Delete, Comma operators

Void operator

Void is a unary operator that can appear before an expression with any value. It always discards its operand value and simply returns an undefined value.

Example of void operator

function hello()

{

alert("function entered");

return true:

}

alert(hello());
Typeof operator

The typeof operator is used to check the data type of its operand such as a variable, a function or an object. Typeof operator returns the type of data that a variable holds.

Syntax of typeof operator

typeof operand

Or

typeof (operand)
New operator

The new operator is an unary operator and used to create an instance of an object type.

Example of new operator

new objectname //syntax of new operator
o = new object;
d = new Data();
myarray = new array();
Delete operaor

The delete operator deletes or undefined the object property or array element specified as its operand.

Example of delete operator

delete myarray[5];
Comma operator

The comma operator is also known as parameter delimiter as it delimits the various parameters. It can be used in function when we have to specify multiple arguments.

Example of comma operator in for loop
 i = 0, j = 1, k = 2 

is equal to 
 i = 0;
 j = 1;
 k = 2;

Leave a Reply