Giter VIP home page Giter VIP logo

javascript_data-type's Introduction

JavaScript_Data-Type

1. 데이터 타입에 관한 배경지식

자바스크립트 언어는 숫자 타입의 경우 정수형인지, 부동 소수형인지 구분하지 않고 64비트, 즉 8바이트를 확보합니다.

  • 변수 = 변할 수 있는 데이터

  • 식별자 = 변수명

  • 리터널 = 변수에 할당하는 테이터


2. 변수선언과 데이터 할당

  1. ↑ 위에 그림을 보시면 a라는 변수가 @1003이라는 빈 공간을 확보합니다. 하지만 데이터영역에는 아무 값이 없습니다. 이러한 경우 식별자 a만 인식하고 출력시 undefined가 나옵니다. ( 호이스팅 )

  1. ↑ 다음은 데이터영역 @5004에 ' abc '를 저장하고 @1003 공간 즉, 변수 a가 가지고 있는 공간 값에 저장합니다. 이러한 경우 값이 채워지게 됐으므로 a를 출력시 **' abc '**라는 값을 출력합니다.

2-1. ↑ 이 그림을 보시면은 @1003이라는 변수 a의 공간에 값을 @5004 주소를 넣었지만, @5005라는 주소값으로 바꾼 것을 볼 수 있습니다. 변수는 그대로 있고 값 영역에 주소만 바뀌었습니다. 변수 a를 출력시 @5005의 값인 ' abcdef ' 출력됩니다.

ex) 만약에 500개의 변수를 생성해서 모든 변수에 숫자 5를 할당한다면?

  • 위에서 언급했듯이 하나의 변수 공간을 생성할 때 8 바이트를 확보해야 합니다. 그리하여 500개의 변수를 생성할 때는 ( 500 * 8 ) = 4000 바이트가 소모가 됩니다.

  • 그러나 위에서 데이터 값에 주소를 저장해 주는 방식은 1 바이트만 소모가 됩니다. 그리하여 숫자 5를 한 번만 저장하고 해당 주소만 변수 영역에 저장하는 게 더 효율적으로 메모리 공간을 사용할 수 있습니다! ( 508byte )

** 결론 = 메모리 공간 사용량 4000 byte < 508 byte**


3. 변수 안에서 선언된 배열이나 키값이 메모리에 저장되는 방식

javascript_data-type's People

Contributors

sungwbs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.