# Custom representation for object in the output cell?

**URL:** <https://talk.observablehq.com/t/custom-representation-for-object-in-the-output-cell/412>\
**Category:** Feedback\
**Created:** [February 23, 2018, 8:18pm UTC](https://talk.observablehq.com/t/custom-representation-for-object-in-the-output-cell/412 "2018-02-23T20:18:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xdze2](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/xdze2/32/280_2.png) [@xdze2](https://talk.observablehq.com/u/xdze2)\
**Post date:** [February 23, 2018, 8:18pm UTC](https://talk.observablehq.com/t/custom-representation-for-object-in-the-output-cell/412/1 "2018-02-23T20:18:34Z")

</div>

Hi,

As an example, I am creating a simple `Vector` prototype to do some geometric computation :

> u = new Vector( [2, 4] )

the folded output is:

> Vector { coords: Array(2) }

In this situation, the folded output gives no information about the actual object. It would be great to have the possibility to define a custom output format for an object. I think about the ` __repr__ ()` method in python. Maybe there is already a way around this I don’t know ? I have tried to change the `toString()` method…

Similarly, sometimes the definition is more valuable than the output.

For example, here I want to plot the function y = f(x).

 ![Screenshot_outputVSequation](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/1X/a101d13610885824b07486ebacef0ba1ee75dd6a.png)

I would prefer to keep visible the definition only and not the output, which is a large unreadable array and provides me no more information than the graph.

Thanks for the work!! It is already a hard choice between Jupyter notebook&Python and Observable…

---

<div class="post-metadata">

**Author:** ![jjimenez](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jjimenez/32/237_2.png) [@jjimenez](https://talk.observablehq.com/u/jjimenez)\
**Post date:** [February 23, 2018, 10:44pm UTC](https://talk.observablehq.com/t/custom-representation-for-object-in-the-output-cell/412/2 "2018-02-23T22:44:54Z")

</div>

in [Manual Mutable Values](https://beta.observablehq.com/@jashkenas/manual-mutable-values), @jashkenas defines a function that shows how to provide a value and a view for an object. That might be a way to solve your problems.

If you put a wrapper wrapper function around your Vector method, you can display whatever you like 🙂

---

<div class="post-metadata">

**Author:** ![tom](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tom/32/2262_2.png) [@tom](https://talk.observablehq.com/u/tom)\
**Post date:** [February 23, 2018, 10:48pm UTC](https://talk.observablehq.com/t/custom-representation-for-object-in-the-output-cell/412/3 "2018-02-23T22:48:59Z")

</div>

To share some of our plans here:

- There’ll be plenty of ‘userland’ solutions possible already and in the future, like `viewof` cells

In the works is an implementation of devtoolsFormatters, a semi-obscure but _hella cool_ way to provide custom formatters for object types, and the situation you propose will be perfect for them. See the [Immutable devtools formatter](https://github.com/andrewdavey/immutable-devtools) for example: we plan to support the same API but to make it available outside of your browser’s devtools and on the page, and in all browsers rather than just Chrome.
