Limiting Object.Prototype Possible?

14 views
Skip to first unread message

Brandon Jonson

unread,
Jun 8, 2016, 4:27:56 PM6/8/16
to v8-users
I've added custom code that extends Object to include a few other functions. Of course anybody could now go in and overwrite those or add their own functions simply by doing Object.Prototype.xxx = xxx. Is there an official way of locking that ability in V8 so at least the functions added could not be overwritten?

Thanks!

Spencer Killen

unread,
Jun 13, 2016, 8:22:09 PM6/13/16
to v8-u...@googlegroups.com
In javascript you can use property descriptors to prevent overwriting. I'd imagine you could get v8 to set them on your functions


On Wed, Jun 8, 2016 at 2:27 PM, Brandon Jonson <brandon....@gmail.com> wrote:
I've added custom code that extends Object to include a few other functions. Of course anybody could now go in and overwrite those or add their own functions simply by doing Object.Prototype.xxx = xxx. Is there an official way of locking that ability in V8 so at least the functions added could not be overwritten?

Thanks!

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Spencer wrote this

Brandon Jonson

unread,
Jun 14, 2016, 11:57:01 AM6/14/16
to v8-users
Hey Spencer,

Thanks for responding to this! This worked like a charm. Looks like I need to do a better job at reading the docs. 

This bare minimum worked with some caveats...

Object.defineProperty(Object.Prototype, 'nameOfFunction', {
  enumerable: false,
  configurable: false,
  writable: false,
  value: function() {
    //do work, return
    return "hello world";
  }
});
Reply all
Reply to author
Forward
0 new messages