Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the prototype of the String constructor function (String.__proto__)?

var mString = new String('A');

console.log(typeof mString); // object

console.log(mString instanceof String); // true

console.log(mString instanceof Object); // true

console.log(mString.__proto__ === String.prototype); // true

console.log(mString.__proto__.__proto__ === Object.prototype); // true 

Now, why

console.log(String.__proto__.__proto__ === Object.prototype); // true

and not

console.log(String.__proto__ === Object.prototype); // false

when walking up the prototype chain?

What is between String and Object prototypes?

like image 270
JSstruck Avatar asked Jan 18 '26 19:01

JSstruck


1 Answers

Function.prototype === String.__proto__ //true

It's a function's prototype, because String is a constructor function.

like image 144
Michael Kurowski Avatar answered Jan 21 '26 08:01

Michael Kurowski