Hi, iam looking to understand difference between object (o) with lowercase and Object (O) with upper case.
`function Bird(){
this.name=“sweety”;
}
var object=new Bird();
console.log(Object);
console.log(object);
output 1-ƒ Object() { [native code] }
output 2- Bird {name: “sweety”}`
what is output 1???
samolex
September 22, 2020, 8:06am
2
Object
is a data type . While in your case object
is an instance of the constructor function, without storing the reference of new Bird
in the variable object
, object is nothing in JavaScript.
Marmiz
September 22, 2020, 8:14am
3
Object() refers to the Object class constructor.
So Object
is a class that exist in JavaScript, while object
was a variable you defined.
You can test it by opening the browser console and typing
console.log(object)
// Error: object is not defined
On the other hand if you type
console.log(Object)
// function Object()
Hope it helps
@samolex @Marmiz thanks…
this help quite a bit