Operators

Loading...

Overview

See MDN 'Expressions and operators'

Shared JavaScript

This section contains code that's shared by experiments on this page. For example, the OperatorsLogHelper provides convenience methods for logging certain operator experiments.

Unary operators

delete

Removes a property from an object. However, if a property with the same name exists up the prototype chain, then the inherited property will become exposed by the object.

delete property

Delete property from simple Object

Delete property from subclass

This example illustrates what happens when a property is deleted from a subclass, but the superclass has a property of the same name.

Delete property from array

This example illustrates what happens when an array item is deleted.

Note: Deleting an item in an array does not remove the slot from the array. See Array.splice to remove an item.

typeof

Using parseInt or Number is a bit dangerous for detecting if a string is numeric, since all non-numeric values resolve to NaN, which is a type of number (e.g., typeof parseInt('xx3') is "number").

typeof undefined

typeof object

typeof number

typeof boolean

typeof string

Relational Operators

in

propIndex in array propName in objInstance

instanceof

object instanceof constructor