We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
μμ볡μ¬
const obj1 = { a : b, b : 2 }; const obj2 = obj1; console.log( obj1 === obj2 ); // true console.log(obj1); // {a: 1, b: 2} console.log(obj2); // {a: 1, b: 2}
μ΄ μμμ²λΌ κ°μ²΄λ₯Ό μ§μ λμ νλ κ²½μ° μ°Έμ‘°μ μν ν λΉμ΄ μ΄λ£¨μ΄μ§λ―λ‘ λμ κ°μ λ°μ΄ν° (μ£Όμ)λ₯Ό κ°μ§κ³ μλ€. μ΄κ²μ μμ 볡μ¬λΌκ³ νλ€.
κΉμ볡μ¬
const dog = {a: 1, b: 2}; const cat = {...dog}; cat.a = 100; console.log(dog === cat) // false console.log(cat.a) // 1
...(spread) μ°μ°μλ₯Ό ν΅ν΄ λΈλ‘ μμ dogμ μμ±μ 볡μ¬νλ©° catμ ν λΉνμλ€. μ΄μ dogμ catμ λ€λ₯Έ μ£Όμλ₯Ό κ°κ² λμλ€. λ©λͺ¨λ¦¬ μ°Έμ‘°κ° λ€λ₯Έ κ².
The text was updated successfully, but these errors were encountered:
No branches or pull requests
4. μμλ³΅μ¬ κΉμλ³΅μ¬ κ°λ
π4-1. μμλ³΅μ¬ (shallow copy)λ ?
μμ볡μ¬
μ΄ μμμ²λΌ κ°μ²΄λ₯Ό μ§μ λμ νλ κ²½μ° μ°Έμ‘°μ μν ν λΉμ΄ μ΄λ£¨μ΄μ§λ―λ‘ λμ κ°μ λ°μ΄ν° (μ£Όμ)λ₯Ό κ°μ§κ³ μλ€. μ΄κ²μ μμ 볡μ¬λΌκ³ νλ€.
π4-2. κΉμ λ³΅μ¬ (Deep copy)λ ?
κΉμ볡μ¬
...(spread) μ°μ°μλ₯Ό ν΅ν΄ λΈλ‘ μμ dogμ μμ±μ 볡μ¬νλ©° catμ ν λΉνμλ€. μ΄μ dogμ catμ λ€λ₯Έ μ£Όμλ₯Ό κ°κ² λμλ€. λ©λͺ¨λ¦¬ μ°Έμ‘°κ° λ€λ₯Έ κ².
The text was updated successfully, but these errors were encountered: