"JavaScript: When prototype is not an object"

🔥 JavaScript: When “prototype” is NOT an object 👀 We all learn early — > “Every function in JavaScript has a prototype property that is an object.” But JavaScript loves exceptions 😏 Here are some surprising cases where prototype is not an object 👇 RegExp.prototype // → /(?:)/ Array.prototype // → [] Function.prototype // → ƒ () {} Number.prototype // → Number {} String.prototype // → String {} Boolean.prototype // → Boolean {} Symbol.prototype // → Symbol {} BigInt.prototype // → BigInt {} 💡 Notice something? Some of these are functions, arrays, or even regular expressions! That’s because their prototypes are actual instances of their types, not plain objects — so that all instances inherit their core methods directly. For example: Array.prototype.push === [].push // true ✅ RegExp.prototype.test === /abc/.test // true ✅ So next time you assume prototype is always {}, remember — JS is full of living examples 😉 --- 💬 Have you ever found a weird prototype behavior while debugging? Drop it in the comments — let’s break more JS myths together! ⚙️ #JavaScript #WebDevelopment #LearningEveryday #Frontend

To view or add a comment, sign in

Explore content categories