I recently watched a guide and wanted better understanding about the concept of hasOwnProperty.
According to Mozilla:
"The hasOwnProperty() method returns a boolean indicating whether the object has the specified property as own (not inherited) property."
I created an object
var test = {yes:function(){}}
and then did
test.hasOwnProperty('toString')
and it returned false. Its because toString is a method that i did NOT create right inside test right?
But then if I log hasOwnProperty to an array and pass length, so
var arr1 = new Array
arr.hasOwnProperty('length') //appears to return true
It returns true, but I never declared length.
I thought hasOwnProperty only works on properties NOT inherited -
so why does using hasownprop('length') on an array return true when the array object inherits the length property,
but
var test = {yes:function(){}}
test.hasOwnProperty('toString') //false
why^ does this return false? toString is method on the object's prototype and I see it when I log it into the Google Chrome Console