Introduction
Built-in methods help you do common tasks quickly without writing extra code. They save time and make your programs easier to read.
Built-in methods help you do common tasks quickly without writing extra code. They save time and make your programs easier to read.
object.methodName(arguments)
toUpperCase() method.let text = "hello"; let upper = text.toUpperCase();
push() method.let numbers = [1, 2, 3]; numbers.push(4);
includes() method.let name = "Alice"; let hasA = name.includes("A");
This program shows how built-in methods help change text and check content easily.
let message = "hello world"; // Use built-in method to make uppercase let shout = message.toUpperCase(); // Use built-in method to check if 'WORLD' is inside let hasWorld = shout.includes("WORLD"); console.log(shout); console.log(hasWorld);
Built-in methods are tested and optimized, so they usually work faster than custom code.
Using them makes your code shorter and easier to understand.
Built-in methods save time by doing common tasks for you.
They make your code cleaner and easier to read.
Use them to work with strings, arrays, numbers, and more.
toUpperCase() on a string text?variable.method().toUpperCase(), so calling text.toUpperCase() is correct.const fruits = ['apple', 'banana', 'cherry'];
const result = fruits.includes('banana');
console.log(result);includes() does on arraysincludes() method checks if an array contains a specific value and returns true or false.fruits contains 'banana', so fruits.includes('banana') returns true.let name = 'Alice'; let lower = name.lowercase(); console.log(lower);
toLowerCase(), not lowercase().name.lowercase() causes a TypeError because the method does not exist.[1, 2, 3, 4, 5]. You want to create a new array with each number doubled using a built-in method. Which code correctly does this?map() creates a new array by applying a function to each element. forEach() runs a function but returns undefined. filter() selects elements based on a condition. reduce() combines elements into a single value.map() is the correct method to transform each element and return a new array.Pass the test and this pattern moves unknown