0

I'm trying to import a function from an App.js (it checks the string in the URL) to another module, but outside App.js the function returns an [object Object]. Tell me, please, what could be the reason? I tried different syntax for export, the result is the same.

export function itTest(){
    const mobileAp = location.search.indexOf("mobile=true") > -1;
    return ( mobileAp
    )}

const test = {itTest};
console.log(test)
[object Ojbect]

1 Answer 1

1

you're creating an object with a field itTest that wraps the function

const test = {itTest};

if you want to have an alias change it to

const test = itTest;

or just use itTest directly

Sign up to request clarification or add additional context in comments.

2 Comments

oh, thank you very much! But do not tell me why when I call a function, I get the function code, not the result?
in your sample code, you're not actually calling the function. itTest is a reference to the function, you can call it with itTest()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.