-
자바스크립트 개발자라면 꼭 알아야 할 표준 내장 객체!웹개발/JavaScript 2024. 7. 27. 17:25728x90
자바스크립트의 표준 내장 객체란?
안녕, 친구들! 오늘은 자바스크립트에서 꼭 알아야 할 표준 내장 객체에 대해 얘기해볼 거야. 이 객체들은 자바스크립트 엔진에 기본적으로 내장되어 있어서 언제 어디서나 사용할 수 있어! 😎
표준 내장 객체란?
표준 내장 객체는 자바스크립트 엔진에 항상 존재하는 객체들이야. 덕분에 우리가 코드를 작성할 때 정말 유용하게 쓸 수 있어. 대표적인 표준 내장 객체에는 다음과 같은 것들이 있어:
- Object
- Function
- Array
- String
- Boolean
- Number
- Math
- Date
- RegExp
이 모든 걸 한 번에 기억하는 건 어려워. 그래서 필요할 때마다 문서를 참고하면 돼! 📚
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects
기본 자료형 & 참조 자료형이 전부 객체였다?
놀랍게도, 우리가 앞에서 배운 기본 자료형과 참조 자료형은 전부 표준 내장 객체에서 파생된 것들이야. 그래서 자바스크립트를 "객체로 이루어진 언어"라고 부르기도 해. 🤯
숫자(Number)
let numLiteral = 10; let numObject = new Number(10); console.log(numLiteral + numObject); // 20 console.log(numLiteral == numObject); // true
문자(String)
let strLiteral = "abc"; let strObject = new String("abc"); console.log(strLiteral + strObject); // abcabc console.log(strLiteral == strObject); // true
논리형(Boolean)
let booleanLiteral = true; let booleanObject = new Boolean(true); console.log(booleanLiteral == booleanObject); // true
배열(Array)
let arrLiteral = [10, 20, 30]; let arrObject = new Array(10, 20, 30); console.log(arrLiteral[0]); // 10 console.log(arrObject[0]); // 10
객체(Object)
let objLiteral = {name: '철수', age: 20}; let objObject = new Object({name: '철수', age: 20}); console.log(objLiteral.name); // 철수 console.log(objObject.name); // 철수
함수(Function)
function sum(a, b) { return a + b; } console.log(sum(10, 20)); // 30 let sumObject = new Function('a', 'b', 'return a + b'); console.log(sumObject(10, 20)); // 30
728x90'웹개발 > JavaScript' 카테고리의 다른 글
자바스크립트 문자열 객체 완벽 가이드 (0) 2024.07.27 자바스크립트 배열 객체 완벽 가이드 (0) 2024.07.27 자바스크립트 이벤트 모르면 나가라. (2) 2024.07.20 DOM(Documents Object Model)이 뭐야!?@!?? (0) 2024.07.20 자바스크립트의 함수 선언 및 표현 방법을 알려줄게! (0) 2024.07.18