메서드(Method)
Number method
let num = 4532
let a = num.toString()
console.log(a)
- Number.isInteger()
-값이 정수인지 판별
let a = Number.isInteger(3)
console.log(a)
let a = Number.isInteger(0.34)
console.log(a)
- toFixed()
-소수 자릿수를 지정하고 문자열로 반환(반올림됨)
let num = 3.4567
let a = num.toFixed(3)
console.log(a)
let num = 3.4567
let a = num.toFixed(2)
console.log(a)
String method
let str = "Hello world!"
let a = str.indexOf("world")
console.log(a)
let str = "Hello world!"
let a = str.indexOf("e")
console.log(a)
let str = "Hello World!"
let a = str.slice(0, 5)
console.log(a)
- trim()
-문자열 양쪽 공백 제거 (중간에 있는 공백은X)
let str = " Hello World! "
let a = str.trim()
console.log(a)