List the special operators used in JavaScript.
Answers
Operator Description
condition ? expr1 : expr2 Returns the value of expr1 if condition is true, or the value of expr2 if condition is false. This operator can be used as a shortcut for the if statement.
expr1 , expr2 Evaluates both expressions and returns the value of expr2. This operator can be used to put multiple expressions in one statement, typically var and for.
delete objectName Deletes objectName. Returns true if the deletion succeeds; otherwise, returns false. Attempting to access a deleted object causes a runtime error. Objects include variables.
delete objectName.property Deletes a user-defined property of objectName (not a predefined property). Sets the property value to undefined and returns true if the deletion succeeds; otherwise, returns false.
delete property Same as delete objectName.property but is used as part of a with statement.
delete objectName[index] Do not use. To "delete" an element of an array, assign the value undefined to the array element.
function(param, param, ...) { statements } Declares an anonymous function in an expression.
function name(param, param, ...) { statements } Declares a named function in an expression.
objectName = new objectType(param, param, ...) Creates an object based on a built-in or user-defined object type.
this Refers to the object that initiated execution. If you call a function, this inside the function refers to the calling object. If you create an object based on a function, this inside the function refers to the function.
this.propertyName Refers to a property (variable) of the object that initiated execution.
typeof operand Returns a string indicating the type of the operand. The operand can be an object, property, variable, or literal. Common types are number, string, boolean, object, function, and null.
typeof(operand) Same as typeof operand.
void expression Evaluates an expression without returning a value.
void(expression) Same as void expression.
object.property Refers to an object property (variable). The property name must be a valid identifier.
object["property"]
object['property']
Refers to an object property (variable). The property name can be any string.