[{"data":1,"prerenderedAt":203},["ShallowReactive",2],{"term-p\u002Fpolymorphism":3,"related-p\u002Fpolymorphism":189},{"id":4,"title":5,"acronym":6,"body":7,"category":171,"description":172,"difficulty":173,"extension":174,"letter":16,"meta":175,"navigation":176,"path":177,"related":178,"seo":183,"sitemap":184,"stem":187,"subcategory":6,"__hash__":188},"terms\u002Fterms\u002Fp\u002Fpolymorphism.md","Polymorphism",null,{"type":8,"value":9,"toc":165},"minimark",[10,15,19,23,26,30,154,158,161],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"Polymorphism means the same method call can do different things depending on which object it's called on. Call 'speak()' on a Dog and you get a bark. Call it on a Cat and you get a meow. Same interface, different behavior. It's shape-shifting for code.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Polymorphism allows objects of different types to be treated uniformly through a shared interface. Runtime polymorphism (dynamic dispatch) selects the correct method implementation at runtime. Enables writing generic code that works with any conforming type without knowing the specific implementation.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const animals: Animal[] = [new Dog(), new Cat(), new Bird()];\nanimals.forEach(a => console.log(a.speak()));\n\u002F\u002F 'woof', 'meow', 'tweet'\n","javascript","",[38,39,40,104,147],"code",{"__ignoreMap":36},[41,42,45,49,53,57,61,64,67,70,73,77,80,83,86,89,91,93,95,98,101],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"spNyl","const",[41,50,52],{"class":51},"sTEyZ"," animals",[41,54,56],{"class":55},"sMK4o",":",[41,58,60],{"class":59},"sBMFI"," Animal",[41,62,63],{"class":51},"[] ",[41,65,66],{"class":55},"=",[41,68,69],{"class":51}," [",[41,71,72],{"class":55},"new",[41,74,76],{"class":75},"s2Zo4"," Dog",[41,78,79],{"class":51},"()",[41,81,82],{"class":55},",",[41,84,85],{"class":55}," new",[41,87,88],{"class":75}," Cat",[41,90,79],{"class":51},[41,92,82],{"class":55},[41,94,85],{"class":55},[41,96,97],{"class":75}," Bird",[41,99,100],{"class":51},"()]",[41,102,103],{"class":55},";\n",[41,105,107,110,113,116,119,123,126,129,131,134,137,139,142,145],{"class":43,"line":106},2,[41,108,109],{"class":51},"animals",[41,111,112],{"class":55},".",[41,114,115],{"class":75},"forEach",[41,117,118],{"class":51},"(",[41,120,122],{"class":121},"sHdIc","a",[41,124,125],{"class":47}," =>",[41,127,128],{"class":51}," console",[41,130,112],{"class":55},[41,132,133],{"class":75},"log",[41,135,136],{"class":51},"(a",[41,138,112],{"class":55},[41,140,141],{"class":75},"speak",[41,143,144],{"class":51},"()))",[41,146,103],{"class":55},[41,148,150],{"class":43,"line":149},3,[41,151,153],{"class":152},"sHwdD","\u002F\u002F 'woof', 'meow', 'tweet'\n",[11,155,157],{"id":156},"when-youll-hear-this","When You'll Hear This",[16,159,160],{},"\"Polymorphism lets us add new animal types without changing the loop.\" \u002F \"That's the power of polymorphism — same interface, different behaviors.\"",[162,163,164],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":106,"depth":106,"links":166},[167,168,169,170],{"id":13,"depth":106,"text":14},{"id":21,"depth":106,"text":22},{"id":28,"depth":106,"text":29},{"id":156,"depth":106,"text":157},"architecture","Polymorphism means the same method call can do different things depending on which object it's called on. Call 'speak()' on a Dog and you get a bark.","intermediate","md",{},true,"\u002Fterms\u002Fp\u002Fpolymorphism",[179,180,181,182],"Inheritance","Abstraction","Open-Closed","Strategy Pattern",{"title":5,"description":172},{"changefreq":185,"priority":186},"weekly",0.7,"terms\u002Fp\u002Fpolymorphism","HV5gmQq37k3FPSdlq4r8N4lp2EzkdZSnOyCgxXLoirA",[190,194,197,200],{"title":180,"path":191,"acronym":6,"category":171,"difficulty":192,"description":193},"\u002Fterms\u002Fa\u002Fabstraction","beginner","Abstraction is hiding the messy details and showing only what matters.",{"title":179,"path":195,"acronym":6,"category":171,"difficulty":192,"description":196},"\u002Fterms\u002Fi\u002Finheritance","Inheritance lets a class take on all the properties and behaviors of another class.",{"title":181,"path":198,"acronym":6,"category":171,"difficulty":173,"description":199},"\u002Fterms\u002Fo\u002Fopen-closed","Open-Closed means your code should be open for adding new features but closed for editing old working code.",{"title":182,"path":201,"acronym":6,"category":171,"difficulty":173,"description":202},"\u002Fterms\u002Fs\u002Fstrategy-pattern","You're writing a sorter and want to sort by price, name, or date depending on user choice.",1776518302529]