# JS function() and () =\> binding for prototype

**URL:** <https://forum.codewithmosh.com/t/js-function-and-binding-for-prototype/4348>\
**Category:** JavaScript\
**Created:** [April 22, 2021, 10:44am UTC](https://forum.codewithmosh.com/t/js-function-and-binding-for-prototype/4348 "2021-04-22T10:44:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nileshchakkarwar](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@nileshchakkarwar](https://forum.codewithmosh.com/u/nileshchakkarwar)\
**Post date:** [April 22, 2021, 10:44am UTC](https://forum.codewithmosh.com/t/js-function-and-binding-for-prototype/4348/1 "2021-04-22T10:44:51Z")

</div>

function inherit(Child,Parent){

```
Child.prototype = Object.create(Parent.prototype);

Child.prototype.constructor = Child;

```

}

function Shape(color){

```
this.color = color;

```

}

Shape.prototype.duplicate = function() {console.log(`Duplicate Color: ${this}`)}; //refers to the correct object i.e Circle. How did this binding happen and why is that not applicable for ()=\> shown below.?

function Circle(radius,color){

```
Shape.call(this,color);

this.radius = radius;

```

}

inherit(Circle,Shape);

Circle.prototype.draw = () =\> {console.log(`Draw!! Radius:-${this}`)}; //this here refers to global object!

let c = new Circle(1,‘Blue’);
