๋ฌธ์์ด.length();
const str = "Hello, world";
console.log(str.length);
// 12
const str = "Hello, world";
console.log(str.indexOf("world"));
// 7
: ๋ฌธ์์ด.slice(์์์์น, ์ข ๋ฃ์์น);
const str = "Hello, world";
console.log(str.slice(0, 5));
//Hello
: ๋ฌธ์์ด.replace(โ์ฐพ์ ๋ฌธ์โ , โ๋ฐ๊ฟ ๋ฌธ์โ);
const str = "Hello, world";
console.log(str.replace("world", "๋ฝ๋ก๋ก"));
// Hello, ๋ฝ๋ก๋ก
๋ฌธ์์ด.repeat(๋ฐ๋ณต ํ์);
let str = "์ฐ์";
let longStr = str.repeat(10) + "์ฐ";
console.log(longStr);
//์ฐ์์ฐ์์ฐ์์ฐ์์ฐ์์ฐ
const str = " Hello, world ";
console.log(str.trim());
// Hello, world
์ ์ํ ๋ณํ : ์ ์ํ ๋ณํ : parseInt()
๋ถ๋์์ ๋ณํ : parseFloat()
(๋ถ๋์์๋ 0.5์ฒ๋ผ ์์์๋ฆฌ๊ฐ ์๋ ์ซ์๋ฅผ ์๋ฏธํ๋ค)
const pi = 3.14159265358979;
console.log(pi);
let int = parseInt(pi);
let float = parseFloat(pi);
console.log(int); // ์ ์ 3์ด ์ถ๋ ฅ๋จ
console.log(float); // 3.14159265358979 ๋ถ๋์์ ํํ๋ก ์ถ๋ ฅ๋จ
console.log(typeof int, typeof float); // number๋ผ๊ณ ์ถ๋ ฅ๋จ
console.log("abs: ", Math.abs(-999)); // ์ ๋๊ฐ 999
console.log("min: ", Math.min(10, 33)); // ์์ ๊ฐ 10
console.log("max: ", Math.max(10, 33)); // ํฐ ๊ฐ 33
console.log("ceil: ", Math.ceil(3.14)); // ์ฌ๋ฆผ 4
console.log("floor: ", Math.floor(3.14)); // ๋ฒ๋ฆผ 3
console.log("round: ", Math.round(3.6)); // ๋ฐ์ฌ๋ฆผ 4
console.log("round: ", Math.round(3.4)); // ๋ฐ์ฌ๋ฆผ 3
console.log("random: ", Math.random()); // ๋๋ค ์๋ฌด์ซ์