Bỏ qua để đến nội dung

Built-in Objects

Built-in objects (còn gọi là global objects) là những đối tượng được tích hợp sẵn trong ngôn ngữ JavaScript, có thể sử dụng ở mọi nơi trong chương trình mà không cần khai báo hoặc import.


Đối tượngChức năng chính
NumberLàm việc với số: toFixed(), toPrecision(), toString(), isNaN(), isFinite()
MathHằng số và hàm toán học: Math.PI, Math.sqrt(), Math.pow(), Math.abs(), Math.floor(), Math.ceil(), Math.round(), Math.random()
DateThời gian và ngày tháng: getFullYear(), getMonth(), getDate(), getHours(), toDateString(), toLocaleString()
StringXử lý chuỗi: length, toUpperCase(), toLowerCase(), substring(), slice(), replace(), includes(), split(), trim(), charAt()
BooleanGiá trị logic: valueOf(), toString()
FunctionCác hàm: call(), apply(), bind(), length, name, toString()
ErrorXử lý lỗi: message, name, stack
ArrayMảng: push(), pop(), shift(), unshift(), map(), filter(), reduce(), forEach(), find(), includes(), sort()
ObjectĐối tượng: keys(), values(), entries(), assign(), hasOwnProperty(), toString()
MapBản đồ: set(), get(), has(), delete(), clear(), size
SetTập hợp: add(), delete(), has(), clear(), size

Math.PI; // 3.141592653589793
Math.sqrt(16); // 4
Math.floor(4.7); // 4
Math.ceil(4.2); // 5
Math.round(4.5); // 5
Math.random(); // Số ngẫu nhiên 0 → 1
Math.abs(-5); // 5
Math.pow(2, 3); // 8