Why is the General function of the prototype works in different constructors (BEWARE, NEWBIE!)?

Hello. Got to OOP and prototypes. The First and Second prototype - Object and it is common for all functions. So that's why the method is written in the prototype does not work in other functions in the constructor? I would be very grateful for the answer!

function First() {
return;
}

function Second() {
return;
}

console.log(First.prototype) // Object {}
console.log(Second.prototype) // Object {}

First.prototype.func = function() {
 return 'the Method of the prototype!'
}

var a = new First();
var b = new Second();

console.log(a.func()) // Method prototype!
console.log(b.func()) // b.func is not a function

console.log(a.func()) // a.func is not a function
console.log(b.func()) // b.func is not a function
July 8th 19 at 12:06
2 answers
July 8th 19 at 12:08
Solution
Prototypes First and Second are two different object, though, and look the same "Object {}"
Therefore, the method added to the prototype of the First available in its instance of a and not available in the instance of b Second.
And how to bring the main prototype Object, which is the prototype for all in one place? First.prototype.prototype(the logic)? - Shaniya commented on July 8th 19 at 12:11
The logic of this Object.prototype - Dolores40 commented on July 8th 19 at 12:14
July 8th 19 at 12:10
Not a very good way, but who prevents to extend the prototype of the parent? That's such a sinful way the number in my application find format:

/* The format method of the Number constructor >>>
 * Extension of the prototype
*
 * Method allows you to specify the number of decimal places and
 * Enter the currency sign before or after the value.
*
 * Example of work: (123456789.12345).format(2, 2, '—', '=')
 * returns: 1-23-45-67-89=12
*
 * All Number instances inherit from Number.prototype.
*/
Number.prototype.format = function (n, x, s, c) {
 var re = '\\d(?=(\\d{' + (x|| 3) + '})+' + (n > 0 ? '\\D' : '$') + ')';
 var num = this.toFixed(Math.max(0, ~~n));

 return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));
};


And so used:

Number(condPriceMin).format(0, 3, ' ', '.') + '<i class="fa fa-rub"></i>';

Find more questions by tags JavaScript