「JavaScript」bindメソッドを利用するサンプル
書式
関数名.bind()
サンプルコード
<script>
function funcA() {
console.log(this);
}
const res = funcA.bind(456);
res();
</script>
実行結果
Number {456}
Coding Changes the World
書式
関数名.bind()
サンプルコード
<script>
function funcA() {
console.log(this);
}
const res = funcA.bind(456);
res();
</script>
実行結果
Number {456}