# JSDoc: Class: PsychObject

# Class: PsychObject

## util.PsychObject(psychoJS, name)

PsychoObject is the base class for all PsychoJS objects. It is responsible for handling attributes.

## Constructor

#### new PsychObject(psychoJS, name)

##### Parameters:

Name | Type | Description
--- | --- | ---
`psychoJS` | module:core.PsychoJS | the PsychoJS instance
`name` | string | the name of the object (mostly useful for debugging)

Source:
  - util/PsychObject.js, line 23

### Extends

- EventEmitter

### Members

#### psychoJS

Get the PsychoJS instance.

Source:
  - util/PsychObject.js, line 46

#### psychoJS

Setter for the PsychoJS attribute.

Source:
  - util/PsychObject.js, line 57

### Methods

#### (protected) _addAttribute(name, value, defaultValueopt, onChangeopt)

Add an attribute to this instance (e.g. define setters and getters) and affect a value to it.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | string |  | the name of the attribute
`value` | object |  | the value of the attribute
`defaultValue` | object | <optional> | the default value for the attribute
`onChange` | function | <optional> | function called upon changes to the attribute value

Source:
  - util/PsychObject.js, line 347

#### (protected) _setAttribute(attributeName, attributeValue, logopt, operationopt, stealthopt) → {boolean}

Set the value of an attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`attributeName` | string |  |  | the name of the attribute
`attributeValue` | object |  |  | the value of the attribute
`log` | boolean | <optional> | false | whether of not to log
`operation` | string | <optional> |  | the binary operation such that the new value of the attribute is the result of the application of the operation to the current value of the attribute and attributeValue
`stealth` | boolean | <optional> | false | whether or not to call the potential attribute setters when setting the value of this attribute

Source:
  - util/PsychObject.js, line 115

##### Returns:

whether or not the value of that attribute has changed (false if the attribute was not previously set)

Type
  boolean

#### toString() → {string}

String representation of the PsychObject.

Note: attribute values are limited to 50 characters.

Source:
  - util/PsychObject.js, line 70

##### Returns:

the representation

Type
  string