DEV Community

Lautaro Suarez
Lautaro Suarez

Posted on

1

Accessing function in object or redux

Let`s see how will you be able to access to a function inside the same object.

In this post i will explain how to do it in objects which is more generally and we are going to go throw an specific case in redux.

Let`s start seeing how to do it in an object.

First we are going to see the case when the functions inside the object are not defining as an arrow function

Image description

As we can see on the first example we are using this in order to be able to call the other function inside the object.

Now let`s see another example of getting the data of an object but in this case when we are defining the function with arrow functions.

Image description

As we can see now with arrow functions we will have to call the object and then the function we want to use in order to able to access it.

Now let's see an example which is basically the same as before but in a real life case.

Let`s say we created a store with reducers and we want to access another reducer within the same object as the other reducer function.

In this specific case we will be defining the object function with arrow function.

Image description

As we can see is basically the same as after. Remember to always think in retrospective and always think about the foundations of javascript it does not matter how complex the code it is.

Hope someone found it helpful, thanks for reading.

Lautaro.

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay