-
[JS] chapter17. νλ‘ν νμ κ³Ό ν΄λμ€codeStates front-end/Java Script 2023. 1. 13. 11:38λ°μν
πνλ‘ν νμ κ³Ό ν΄λμ€
νλ‘ν νμ κΈ°λ° μΈμ΄
νλ‘ν νμ μ μν κ°μ²΄λ₯Ό μλ―Έ
κ°μ²΄μ νΉμ±μ λ€λ₯Έ κ°μ²΄λ‘ μμνλ κ²μ κ°λ₯νκ² νλ 맀컀λμ¦;]
__proto__
νΉμ κ°μ²΄μ νλ‘ν νμ κ°μ²΄μ μ κ·Όν μ μλ property
es6λΆν° getPrototypeof νΈμΆ
__proto__ μ .prototype μ μ°¨μ΄
__proto__
λͺ¨λ κ°μ²΄κ° κ°μ§κ³ μλ€.
νλμ Link λΌκ³ ν μ μλ€.prototype
ν¨μ κ°μ²΄λ§ κ°μ§κ³ μλ€.
μμ±μλ₯Ό κ°μ§λ μνμΌλ‘ μ μΈ ν μ μλ€.μ€μ΅μ½λ
class Human { constructor(name, age) { this.name = name; this.age = age; } sleep() { console.log(`${this.name}μ μ μ λ€μμ΅λλ€`); } } let kimcoding = new Human('κΉμ½λ©', 30); // μ€μ΅ν΄λ³΄μΈμ Human.prototype.constructor === Human; Human.prototype === kimcoding.__proto__; Human.prototype.sleep === kimcoding.sleep;
answer : true, true, true
- Human ν΄λμ€μ μμ±μ ν¨μλ Humanμ λλ€.
- Human ν΄λμ€μ νλ‘ν νμ μ Human ν΄λμ€μ μΈμ€ν΄μ€μΈ kimcodingμ __proto__μ λλ€.
- Human ν΄λμ€μ sleep λ©μλλ νλ‘ν νμ μ μμΌλ©°, Human ν΄λμ€μ μΈμ€ν΄μ€μΈ kimcodingμμ kimcoding.sleepμΌλ‘ μ¬μ©ν μ μμ΅λλ€.
Humanμ΄λΌλ ν΄λμ€μ μΈμ€ν΄μ€, κ·Έλ¦¬κ³ νλ‘ν νμ μ κ΄κ³
Array(λ°°μ΄) ν΄λμ€μ μΈμ€ν΄μ€, κ·Έλ¦¬κ³ νλ‘ν νμ μ κ΄κ³
λ°μν'codeStates front-end > Java Script' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[JS] μ€μ΅ - Beesbeesbees (0) 2023.01.16 [JS] chapter18. ν¬λ‘ν νμ κ³Ό μ²΄μΈ (0) 2023.01.13 [JS] chapter16. κ°μ²΄ μ§ν₯ - κ°μ²΄ μ§ν₯ νλ‘κ·Έλλ° (0) 2023.01.13 [JS] chapter15. κ°μ²΄ μ§ν₯ - ν΄λμ€μ μΈμ€ν΄μ€ (0) 2023.01.13 [JS] chapter14. κ°μ²΄ μ§ν₯ - ν΄λ‘μ λͺ¨λ ν¨ν΄ (1) 2023.01.13