Skip to content

Instantly share code, notes, and snippets.

@speg

speg/stumped.js Secret

Created July 25, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speg/30abc28a9d83cbf2c8dba897092fd596 to your computer and use it in GitHub Desktop.
Save speg/30abc28a9d83cbf2c8dba897092fd596 to your computer and use it in GitHub Desktop.
Is it possible to change the name printed in the console? What property is the dev tools reading?
function caat() { this.legs = 4; }
// undefined
Object.defineProperty(caat.prototype, "name", {value: "cat"})
// Object {name: "cat"}
caat
// caat() { this.legs = 4; }
milo = new caat()
// caat {legs: 4}
milo
// caat {legs: 4}
caat.name
// "caat"
caat.name = 'kitten'
// "kitten"
caat
// caat() { this.legs = 4; }
milo
// caat {legs: 4}
pooky = new caat()
// caat {legs: 4}
pooky
// caat {legs: 4}
@sylvainpolletvillard
Copy link

Also looking for the answer.

@4strid
Copy link

4strid commented Jun 30, 2018

Commenting so I can watch this thread. I'm making a framework and it's frustrating, having every single component named "Component"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment