Skip to content
Advertisement

Tag: return

How to catch Firebase promise in React?

I have a simple function that checks if the user has Premium access or not: I tried to catch this in various ways, but no luck, it always returns an “undefined” object. What is the correct way to get the returned Boolean value? Answer onSnapshot is meant for listening to a collection continuously, getting repeatedly notified as its value changes.

Variable of function always returns undefined

The idea: I want to return a variable from a function and then output it using console.log(). The problem: I can’t just use return result because then nothing is returned. I don`t really know how else to return the variable. I have already looked at SO posts like this one, however I probably lack suitable understanding to implement this into

Undefined when i am returning an Object in Javascript

I’m doing a getter in VueX, and when i’m returning an object for another function, i have “undefined”. Basically i have a function like that. When i’m showing obj with console.log(obj), i have an object with elements in here. And basically it’s working. But when i’m doing a return and i’m trying to get the obj in another function I

Recursive function returns undefined

I have a function which calculates taxes. I can’t see why it doesn’t stop the recursion. Answer In this arm of your function: you are not returning a value from the function or setting returnTax. When you don’t return anything, the return value is undefined. Perhaps, you want this:

How to make chainable function in JavaScript?

Lets imagine function like this: Usage of it would be like: I’m looking for a way to create function that’s chainable with other functions. Imagine usage: How would I do this? Answer Sure, the trick is to return the object once you’re done modifying it: http://jsfiddle.net/Xeon06/vyFek/ To make the method available on String, I’m modifying it’s prototype. Be careful not

Advertisement