Home πŸ“Έ 2023-01-16
Post
Cancel

πŸ“Έ 2023-01-16

πŸ”₯ 였늘 어디에 도전해보셨고, 무엇을 λ°°μš°μ…¨λ‚˜μš”?

🌊 ν•™μŠ΅ν•˜μ‹œλ©΄μ„œ κΆκΈˆν•˜μ‹  λΆ€λΆ„μ΄λ‚˜, μ–΄λ €μ› λ˜ 점은 λ­˜κΉŒμš”?

  • μžλ°”μŠ€ν¬λ¦½νŠΈ 객체의 getter, setterλ₯Ό μ“Έ λ•Œ, μ•„λž˜ μ½”λ“œμ²˜λŸΌ getter ν•¨μˆ˜λͺ…을 ν”„λ‘œνΌν‹° 이름과 λ™μΌν•˜κ²Œ μ‚¬μš©ν•˜λ©΄ Maximum call stack size exceeded Errorκ°€ λ°œμƒν•œλ‹€. obj.value()둜 getterλ₯Ό ν˜ΈμΆœν•˜λ©΄ return this.valueλΌλŠ” ꡬ문이 valueλΌλŠ” ν”„λ‘œνΌν‹°μ˜ 값을 λ°˜ν™˜ν•˜λŠ”κ²Œ μ•„λ‹ˆλΌ getter ν•¨μˆ˜ 자체λ₯Ό λ°˜ν™˜ν•œλ‹€. λ”°λΌμ„œ λ¬΄ν•œλ°˜λ³΅ν•˜κ²Œ 되고, μ½œμŠ€νƒ 초과 μ—λŸ¬κ°€ λ°œμƒν•œλ‹€.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    const obj = {
      value: "",
      get value() {
        return this.value; //[Exception: RangeError: Maximum call stack size exceeded at get value [as value] (<anonymous>:4:17)...
      },
      set value(value) {
        this.value = value;
      },
    };
    
    obj.value = "A"; //RangeError: Maximum call stack size exceeded
    

    getter-callstack-error

    이λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•΄μ„œ getter,setter둜 νŠΉμ • ν”„λ‘œνΌν‹°μ˜ 값을 μ½κ±°λ‚˜ μˆ˜μ •ν•œλ‹€λ©΄ κ·Έ ν”„λ‘œνΌν‹° 값에 _λ₯Ό λΆ™μ—¬μ£ΌλŠ” 것이 μ’‹λ‹€.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    const obj = {
      _value: "",
      get value() {
        return this._value;
      },
      set value(value) {
        this._value = value;
      },
    };
    
    obj.value();
    obj.value = "A";
    

    🐝 참고

    [JS] Maximum call stack size exceeded ν•΄κ²° | class getter setter μ΄ν•΄ν•˜κΈ°

    getter setter Maximum call stack size exceeded Error - stackoverflow

  • CSS κΈ°λ³Έ μŠ€νƒ€μΌ reset ν•˜λŠ” μ½”λ“œλ₯Ό μ‚¬μš©ν•˜λŠ” κ²½μš°κ°€ μžˆλ‹€κ³  ν•œλ‹€. 말 κ·ΈλŒ€λ‘œ νƒœκ·Έλ§ˆλ‹€ 기쑴에 적용된 속성을 μ΄ˆκΈ°ν™”μ‹œν‚¨λ‹€. (이런 μ‹μœΌλ‘œ μ“°λŠ”κ±° κ°™λ‹€. πŸ‘‰ CSS Tools: Reset CSS - meyerweb.com)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    html,
    body,
    div,
    span,
    h1,
    h2,
    table {
      margin: 0;
      padding: 0;
      border: 0;
      font-size: 100%;
      font: inherit;
    }
    

🌟 내일은 μ–΄λ–»κ²Œ 해보고 μ‹ΆμœΌμ„Έμš”?


This post is licensed under CC BY 4.0 by the author.

ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€ ν‘œ 병합 - μžλ°”μŠ€ν¬λ¦½νŠΈ

πŸ“Έ 2023-01-22