이름이 문자열일 때 JavaScript 함수를 실행하려면 이름으로 클래스 메서드에 액세스할 수 있습니다.
예시
라이브 데모
<html>
<body>
<script>
class Demo {
methodOne(){
document.write("50");
}
methodTwo(){
this['methodOne']();
document.write("<br> 100");
}
}
let num = new Demo();
num['methodTwo']();
</script>
</body>
</html>