1

Recreate the same type of object

As per the Image Im trying to recreat that type of Object . Chrome Dev tools

Console.log(TabPanel) Gives me the return on the object but what I don't understand is how the function name

TabPanel : f TabPanel()

follows the f symbol in the log .

How can I recreate that type of object with a simple example I have tried to use constructors and prototypes . I'm not sure how they achieved this

the console log

2 Answers 2

2

What devtools is showing you there is that the value of TabPanel property on the object you logged is a reference to a function called TabPanel (not an object created by TabPanel, the TabPanel function itself). Here's an example:

function Example() {
}
var o = {
  ex: Example
};
console.log(o);
Look in the real console.

That gives us:

enter image description here

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

1 Comment

Oooohhhhhhhhh Thanks that makes sense.... Would up vote you if i could
1

If you create your function with a name, then it will display like that in your console.

const TabPanel = function TabPanel() {};
console.log(TabPanel);

Will log as you show in your screenshot

If you wanted this as part of an object, you could do:

const TabPanel = {
    TabPanel: function TabPanel() { ... }
}

Which would log as an object, which when expanded would show you your named function.

2 Comments

Thank you but place that in an object like 'TabPanel = {}; TabPanel .TabPanel = (function(){....}); ' you still dont see it like that in chrome log
Yes, by defining a function without a name, it won't show as you desire, because the function has no name. Updated my example

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.