2

Im working with Three.js and javascript. When my code executes this:

console.log(this.scene.children[1])

I get this in my console of Chrome: enter image description here

How can I get the name of the object ('WidgetsRuler') as a string? I dont see any attribute that saves this information.

2 Answers 2

2

Okay I Solved it using:

console.log(this.scene.children[1].constructor.name)
Sign up to request clarification or add additional context in comments.

1 Comment

It says I have to wait 2 days
1

I believe you should be able to use prototype to achieve this:

Object.prototype.toString

eg:

Console.Log(this.scene.children[1].prototype.toString())

Failing that, you can try constructor:

console.log(this.scene.children[1].constructor.name)

4 Comments

Thanks sk93! The console says this.scene.children[1].prototype is undefined :/
I was just editing my answer to show "constructor" instead, but you beat me to it :)
Thanks Sk93! I always find the answer when Ive already posted :´)
please tick your answer (or mine :P) as the accepted answer if this is now solved. the tick should appear below the up/down arrows and big number to the left of the answers. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.