0

I tried below code

var carname = "Volvo XC60";
console.dir(carname);

This gives nothing but the value. I want to list all prototype functions associated with this variable. This one also is not working.

console.dir(carname.prototype);

Any idea what am I doing wrong?

1
  • If you just want to see what methods are available, use the MDN documentation. Commented Jan 23, 2015 at 10:16

2 Answers 2

1

What prototype functions do you want to see? For native try this:

console.log(new String('carname'));
Sign up to request clarification or add additional context in comments.

3 Comments

console.dir(carname); worked! console.log() doesnt log prototypes.
@Shreejibawa my Google Chrome Dev Tools thinks different
@Shreejibawa: Only because primitive strings are no objects, and don't have prototypes.
0

Finally Found it! How could I missed this?

var carname = new String("Volvo XC60");
console.dir(carname);

1 Comment

In Firefox, these function behave quite differently: log only prints out a toString representation, whereas dir prints out a navigable tree. In Chrome, log already prints out a tree -- most of the time. However, Chrome's log still stringifies certain classes of objects, even if they have properties.

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.