JavaScript Special Operators

Notes:

JavaScript Special Operators:

typeof: typeof operator returns the type of a given operand
Ex:
document.write(typeof 5); // number
document.write(typeof "JavaScript"); // string
document.write(typeof true); // boolean
document.write(typeof undefined); // undefined
document.write(typeof null); // object

comma: comma operator returns the RHS operand value
Ex:
var c = (2,2) + (3,5); // same as var c = 2+5
document.write(c);

new: new operator is used to create new instance of an object
Ex:
var stud1 = new Object();
stud1.name="Ramesh";
stud1.rollNum = 1;
document.write(stud1.rollNum," : ",stud1.name);//1:Ramesh

delete: delete operator is used to delete a property of an object
Ex:
delete stud1.rollNum;
document.write(stud1.rollNum," : ",stud1.name);//undefined

Interview Questions: