1
Element.prototype.objProp = new function(){
    this.property = null;
};

Right now what is null I want to set equal to element's ID. My main question is how to access the Element. Whenever I use this keyword it returns the object itself not the Element. What to do?

  • You don't want that `new` keyword in there. What did you think it would do? – Bergi Aug 31 '17 at 10:36
  • [Don't extend native prototypes!](https://stackoverflow.com/q/14034180/1048572) See also [what's wrong with extending the DOM](http://perfectionkills.com/whats-wrong-with-extending-the-dom/). – Bergi Aug 31 '17 at 10:39
  • How do you expect to use `objProp` and `property`, can you show an example? – Bergi Aug 31 '17 at 10:40
  • @Bergi I want to use that new key word cause I want it to be an object, I know why we should not extend native object and I m gonna use it as my advantage... Sry I can't show an example cause I m gonna make a really awesome thing and I don't wanna leak the idea –  Aug 31 '17 at 10:59
  • Well sorry but [your idea is worthless](https://boss.blogs.nytimes.com/2012/10/19/stop-trying-to-protect-your-business-ideas/) if you cannot implement it :-) Please post an example - it does not need to be actual code, it only needs to show *how* you want to use these properties. Honestly I don't care about your idea, but without clear requirements this question will be off-topic on StackOverflow. – Bergi Aug 31 '17 at 11:04
  • No, you neither want an [object on a prototype](https://stackoverflow.com/questions/10131052/crockfords-prototypal-inheritance-issues-with-nested-objects/) nor want to [use `new function` ever](https://stackoverflow.com/questions/10406552/is-it-right-to-think-of-a-javascript-function-expression-that-uses-the-new-key-as-static) – Bergi Aug 31 '17 at 11:05

0 Answers0