Is javascript Object a constructor or an object?

I encountered some confusion when learning the prototype chain as follows:
in some blogs (such as Ruan Yifeng"s blog), it is said:

JavaScript natively provides Object objects, and all other objects inherit from Object objects, that is, those objects are instances of Object
.

I"m confused here. As far as I understand, shouldn"t Object be a constructor? Because, for example, any instance object has a .valueof method, which is actually a referenced
method in the prototype object Object.prototype , and when I type typeof (Object) in the terminal, it returns "function" , indicating that Object should be a constructor, and the real object should be Object.prototype bar

.

but it doesn"t seem to be quite the case. Object has its own static method, which is defined directly in its own method, such as Object.keys () , so the constructor is also an object? Can you also have your own methods and properties?

another test was done:

var F = function() {}
F.__proto__ === Function.prototype // true

how to understand this question? I just learned javascript . After learning these concepts, I began to be a little confused. I hope you seniors can give a clear answer. Thank you

.

however, the "function" is also Object

.
function rua() {}

console.log(rua instanceof Object)

// true

even the "class" is Object

class Rua {}

console.log(Rua instanceof Object)
// true

in js, a class is also an object

in js, everything is Object (except for the basic types), and when you think about it, there is no conflict, which makes js very flexible.

and why do you think a class is (only) a "function"? Constructors are generally used to initialize dynamic data such as class members, and the "class" should also contain static methods and instance methods, which are not part of the "constructor". Of course, if you use the method of dynamically declaring instance methods, then these "methods" are really part of the "constructor".

in order to make you think that Object is also an object, please follow my way of thinking.

  1. in js, objects that can add attributes ( property ) are all objects
  2. . For
  3. classes declared with class reserved words, you are free to add attributes ( property ) (try it otherwise)
  4. the function you declare yourself, feel free to add attributes ( property ) (try it or not)
  5. you can even add attributes to Object at will ( property ) (try it if you don't believe it)

does that make sense?

The

function itself is an object. For prototypes, please refer to prototype


Js everything can be regarded as an object. Object can naturally be regarded as a constructor, but it is also an object. The function itself is an object. The object types in


JavaScript are essentially different from other data types. It makes sense that everything is the object of everything.


the prototype you are talking about is the property of the function, and the function itself is an object. To put it simply, everything is an object.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31682-3415a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31682-3415a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?