목록자바 스크립트 (JavaScript) (43)
종우의 컴퓨터 공간
someType(Number, Bool, Date, Array) to string - = String(); - = ().toString(); someType(String, Bool, Null, Array) to number - = Number() - = parseInt() - = parseFloat() - Bool과 Null 타입에서는 true는 1을, false와 null은 0을 반환한다. - String과 Array와 같은 숫자로 변환할 수 없는 경우에는 NaN(Not a Number)을 반환한다. Type Coersion(강제 형 변환) - 우리가 형 변환을 하는 것이 아니라 자바 스크립트 자체에서 알아서 해준다. const val1 = 5; const val2 = 6; const sum = val..
Primitive Data Type - stroed directly in the location the variable accesses - stored on the stack - String, Number, Boolean, Null, Undefined, Symbols(ES6) Reference Data Type - accessed by reference - objects that are stored on the heap - a pointer to a location in memory - Arrays, Object Literals, Functions, Dates, Anything Else... Dynamically Typed Language - Types are associated with values n..
var - ES6 이후부터 사용하지 않는다. let(변수) - 재할당(reassign)이 가능하다. - block level scope를 가진다. const(상수) - 재할당(reassign)이 불가능하다. - 처음 선언할 때 반드시 초기화(값 할당)을 해주어야 한다. - block level scope를 가진다. - 객체같은 경우에는 그 안의 필드의 값을 변경할 수는 있지만 그 객체 자체를 다른 객체로 변경할 수는 없다. - 배열같은 경우에도 그 안의 값에 추가를 하거나 삭제를 하는 등 변경은 가능 하지만 그 배열 자체를 다른 배열로 변경할 수는 없다. const person = { name: 'Jongwoo', age: 29 } person.name = 'James'; console.log(perso..