Passwordless app authentication is the future. And this tutorial shows you how to easily integrate magic links using Stream & Supabase.
OK this one’s not a bug, but why does this code work?
const friends = ['Alex', 'Ben', 'Mikenzi'] friends.hasOwnProperty('push') // false
Specifically, why does friends.hasOwnProperty('push') work even though friends doesn’t have a hasOwnProperty property and neither does Array.prototype?
Why does this code work?
const friends = ['Alex', 'Ben', 'Mikenzi'] friends.hasOwnProperty('push') // false
As mentioned earlier, if you look at Array.prototype, it doesn’t have a hasOwnProperty method. How then, does the friends array have access to hasOwnProperty?
The reason is because the Array class extends the Object class. So when the JavaScript interpreter sees that friends doesn’t have a hasOwnProperty property, it checks if Array.prototype does. When Array.prototype doesn’t, it checks if Object.prototype does, it does, then it invokes it.
const friends = ['Alex', 'Ben', 'Mikenzi'] console.log(Object.prototype) /* constructor: ƒ Object() hasOwnProperty: ƒ hasOwnProperty() isPrototypeOf: ƒ isPrototypeOf() propertyIsEnumerable: ƒ propertyIsEnumerable() toLocaleString: ƒ toLocaleString() toString: ƒ toString() valueOf: ƒ valueOf() */ friends instanceof Array // true friends instanceof Object // true friends.hasOwnProperty('push') // false