# Arrow functions

**URL:** <https://discourse.processing.org/t/arrow-functions/33715>\
**Category:** Beginners\
**Created:** [November 24, 2021, 1:03pm UTC](https://discourse.processing.org/t/arrow-functions/33715 "2021-11-24T13:03:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clark](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@Clark](https://discourse.processing.org/u/Clark)\
**Post date:** [November 24, 2021, 1:03pm UTC](https://discourse.processing.org/t/arrow-functions/33715/1 "2021-11-24T13:03:26Z")

</div>

Hi. This code is from Roni Kaufman [on OpenProcessing](https://openprocessing.org/sketch/839385)  
Could anyone please explain in a beginner-understandable way what the function below does and how it works?

`let noiseProg = (x) => (x);`

Whole code:

```auto

// By Roni Kaufman

let kMax;
let step;
let n = 80; // number of blobs
let radius = 0; // diameter of the circle
let inter = 0.1; // difference between the sizes of two blobs
let maxNoise = 500;

let noiseProg = (x) => (x);

function setup() {
  createCanvas(600, 600);
  angleMode(DEGREES);
  noFill();
  kMax = random(0.6, 1.0);
  step = 0.01;
  noStroke();
}

function draw() {
  blendMode(BLEND);
  background(0);
  blendMode(ADD);
  let t = frameCount/100;
  for (let i = n; i > 0; i--) {
	let alpha = pow(1 - noiseProg(i / n), 3);
	let size = radius + i * inter;
	let k = kMax * sqrt(i/n);
	let noisiness = maxNoise * noiseProg(i / n);
		
	fill(255, 0, 0, alpha*255);
    blob(size, width/2, height/2, k, t - i * step, noisiness);
		
	fill(0, 255, 0, alpha*255);
    blob(size, width/2, height/2, k, t - i * step + 1, noisiness);
		
	fill(0, 0, 255, alpha*255);
    blob(size, width/2, height/2, k, t - i * step + 2, noisiness);
  }
}

function blob(size, xCenter, yCenter, k, t, noisiness) {
  beginShape();
  let angleStep = 360 / 12;
  for (let theta = 0; theta <= 360 + 2 * angleStep; theta += angleStep) {
    let r1, r2;
    r1 = cos(theta)+1;
    r2 = sin(theta)+1;
    let r = size + noise(k * r1, k * r2, t) * noisiness;
    let x = xCenter + r * cos(theta);
    let y = yCenter + r * sin(theta);
    curveVertex(x, y);
  }
  endShape();
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [November 24, 2021, 5:12pm UTC](https://discourse.processing.org/t/arrow-functions/33715/2 "2021-11-24T17:12:21Z")

</div>

> [@Clark](#):
>
> … what the function below does and how it works?

The statement `let noiseProg = (x) => (x);`, which btW can be re-written as `const noiseProg = x => x;`, does absolutely NOTHING!

More specifically, it’s a function which returns the passed argument w/o doing anything to it; so it’s moot!

Maybe the author did it as an easy way to modify the “noise” behavior later on.

But the way the code is right now you can simply delete it.

And then replace all instances of `noiseProg(i / n)` w/ just `i / n`.

More about JS fat arrow functions:

> **[Arrow function expressions - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)**
>
> An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate limitations in usage:

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [November 29, 2021, 1:18am UTC](https://discourse.processing.org/t/arrow-functions/33715/3 "2021-11-29T01:18:09Z")

</div>

> [@GoToLoop](#):
>
> Maybe the author did it as an easy way to modify the “noise” behavior later on.

That seems quite likely. The function may be a placeholder for what the author deemed a good place for some experimentation. For instance, you can get a different effect by replacing the function with something like this:

```auto
let noiseProg = (x) => (5.0 * x * (1.0 + sin(frameCount * 0.01)));

```

Cropped image of saved frame:

![noisy_orb](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9e6f98cc972d10c2ca0fa334678204f67fe45428.png)
