# Printing a Vector before and after changing it produces unexpected results

**URL:** <https://discourse.processing.org/t/printing-a-vector-before-and-after-changing-it-produces-unexpected-results/32111>\
**Category:** Beginners\
**Created:** [September 6, 2021, 12:33am UTC](https://discourse.processing.org/t/printing-a-vector-before-and-after-changing-it-produces-unexpected-results/32111 "2021-09-06T00:33:58Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![norm\_krumpe](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@norm\_krumpe](https://discourse.processing.org/u/norm_krumpe)\
**Post date:** [September 6, 2021, 12:33am UTC](https://discourse.processing.org/t/printing-a-vector-before-and-after-changing-it-produces-unexpected-results/32111/1 "2021-09-06T00:33:58Z")

</div>

I’m putting together a short exercise for my students on p5.Vector and its operations. The output of the code below surprises me, and I was hoping someone could explain what’s going on. I’ve been programming in Processing for years, but am new to p5.js, and so my unexpected results might have more to do with how javascript works (or how objects work, or how console output works).

Here is the code, along with comments indicating the expected results:

```auto
function setup() {
  let h = new p5.Vector(3, 4);
  // I expect both of these to show 3, 4, 0
  print(h);
  print(h.x, h.y, h.z);       

  // I expect both of these to show 21, 28, 0
  h.mult(7);
  print(h);
  print(h.x, h.y, h.z);
}

```

But when I run it these are the results:

```auto
Vector {x: 21, y: 28, z: 0, constructor: Object}
3 4 0
Vector {x: 21, y: 28, z: 0, constructor: Object}
21 28 0

```

Can someone explain why the output of the individual components produces what I expected, but the output of the Vector objects themselves does not? Processing would have produced the results I expected, but p5.js does not.

Thank you for helping me understand this!

---

_[View the full topic](https://discourse.processing.org/t/printing-a-vector-before-and-after-changing-it-produces-unexpected-results/32111)._
