JavaScript: prototype functions showing up in console -


I have just seen that when I'm logging an example of that object on which I am currently working , (This is only one). I think I am doing something wrong.

Enter image details here

This is how I set the prototype I am doing

  MF = function (x) {if ((this example of MIF)) return new MF (X); This.node = x; } MF.prototype = {Show: Function (display) {display? This.node.style.display = Display: this.node.style.display = 'block'; }, Hide: function () {this.node.style.display = 'none'; }} Console.log (MF (window));  

I also tried to set it to Object.create () , as suggested in, which does not matter much in my case, but Disappointed times disappointed efforts

Why am I seeing prototype methods in the example, and how can I fix it?

Edit:

For example here a JQuery object appears, there is no prototype function shown in the log

Enter the image here

Showing prototype objects is a common practice and with jQuery it has been reproduced as well. Just call console.dir ($ ('div')) and you will see the __proto___ object below. You can not hide prototype functions from showing the console.

Similarly, I apply the prototype extension classes to my library:

  Pinch. $ = Function (selector, guardian) {If (! (This instanceof arguments.callee)) {var callee = arguments.callee, newObject = Object.create (callee.prototype); Callee.apply (newObject, callee.arguments); Return a new object; } // --- logic-- this back; Pinch. Protopep = object Create ({: function ()}, // --- methods --- empty: function () {}});  

And then if you want to expand your prototype in new ways:

  Pinch. $ Prototype = pinch.uthel Extension (pinch. $. Prototype, {NewMethods: function () {}}, {oneMoreMethod: function () {}});  

expansion () You can find the recovery in many libraries and just "Increase JavaScript"

The second way is to objects. Expand:

  Pinch. $ Prototype = object Create (pinch. $ Prototype, {newMethods: function () {}});  

But in reality, you can not hide the prototype object from the console. Only if you start using hacks and trucks based on the local area and more.

UPD: You can use Object.defineProperties () to hide elements -

For example :

var MF = function () {}; MF.prototype = Object. Create ({}); Object.defineProperties (MF.prototype, {thisWillShow: {value: function ()}}, enumerable: true}, this WillNotShow: {value: function () {}, enumerable: false}}); Console.log (new MF ());

And here the examples are working -


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -