Lokang 

JavaScript and MySQL

Built in

Sure, here are examples of each of the JavaScript built-in functions listed:

1. String Functions

charAt(index)

let str = "Hello, World!";
console.log(str.charAt(0)); // "H"

concat(string2, string3, ..., stringX)

let str1 = "Hello";
let str2 = "World";
console.log(str1.concat(", ", str2, "!")); // "Hello, World!"

includes(searchString, position)

let str = "Hello, World!";
console.log(str.includes("World")); // true

indexOf(searchValue, fromIndex)

let str = "Hello, World!";
console.log(str.indexOf("World")); // 7

replace(searchValue, newValue)

let str = "Hello, World!";
console.log(str.replace("World", "Everyone")); // "Hello, Everyone!"

slice(beginIndex, endIndex)

let str = "Hello, World!";
console.log(str.slice(7, 12)); // "World"

split(separator, limit)

let str = "Hello, World!";
console.log(str.split(", ")); // ["Hello", "World!"]

toLowerCase()

let str = "Hello, World!";
console.log(str.toLowerCase()); // "hello, world!"

toUpperCase()

let str = "Hello, World!";
console.log(str.toUpperCase()); // "HELLO, WORLD!"

trim()

let str = "   Hello, World!   ";
console.log(str.trim()); // "Hello, World!"

 

2. Array Functions

concat(array2, array3, ..., arrayX)

let arr1 = [1, 2, 3];
let arr2 = [4, 5, 6];
console.log(arr1.concat(arr2)); // [1, 2, 3, 4, 5, 6]

every(callback)

let arr = [1, 2, 3, 4, 5];
console.log(arr.every(num => num < 6)); // true

filter(callback)

let arr = [1, 2, 3, 4, 5];
console.log(arr.filter(num => num % 2 === 0)); // [2, 4]

forEach(callback)

let arr = [1, 2, 3, 4, 5];
arr.forEach(num => console.log(num * 2)); // 2, 4, 6, 8, 10

indexOf(searchElement, fromIndex)

let arr = [1, 2, 3, 4, 5];
console.log(arr.indexOf(3)); // 2

join(separator)

let arr = ["Hello", "World"];
console.log(arr.join(", ")); // "Hello, World"

 

3. Math Functions

abs(x)

console.log(Math.abs(-10)); // 10

ceil(x)

console.log(Math.ceil(4.2)); // 5

floor(x)

console.log(Math.floor(4.9)); // 4

 

4. Date Functions

getDate()

let date = new Date();
console.log(date.getDate()); // Current day of the month

getDay()

let date = new Date();
console.log(date.getDay()); // Current day of the week (0-6, 0=Sunday)

getFullYear()

let date = new Date();
console.log(date.getFullYear()); // Current year

getMonth()

let date = new Date();
console.log(date.getMonth()); // Current month (0-11, 0=January)

 

5. Number Functions

isFinite(value)

console.log(Number.isFinite(10)); // true
console.log(Number.isFinite(Infinity)); // false

isInteger(value)

console.log(Number.isInteger(10)); // true
console.log(Number.isInteger(10.5)); // false

isNaN(value)

console.log(Number.isNaN(NaN)); // true
console.log(Number.isNaN(10)); // false

parseFloat(string)

console.log(Number.parseFloat("10.5")); // 10.5

parseInt(string, radix)

console.log(Number.parseInt("10", 10)); // 10
console.log(Number.parseInt("10", 2)); // 2 (binary)

These examples cover a wide range of JavaScript's built-in functions, showcasing how they can be used in various contexts.