Edit this page

up.util up.util.isEqual.key
JavaScript property

This feature is experimental. It may be changed or removed in a future version.

This property contains the name of a method that user-defined classes may implement to hook into the up.util.isEqual() protocol.


We have a user-defined Account class that we want to use with up.util.isEqual():

class Account {
  constructor(email) {
    this.email = email

  [up.util.isEqual.key](other) {
    return this.email === other.email

Note that the protocol method is not actually named 'up.util.isEqual.key'. Instead it is named after the value of the up.util.isEqual.key property. To do so, the code sample above is using a computed property name in square brackets.

We may now use Account instances with up.util.isEqual():

let one = new User('foo@foo.com')
let two = new User('foo@foo.com')
let three = new User('bar@bar.com')

up.util.isEqual(one, two)   // returns true
up.util.isEqual(one, three) // returns false


key string