首页 > 解决方案 > JavaScript: binding to a variable

问题描述

This may be a naive but i am not able to understand how javascript assign values to its variables. In this book, i came across the following code.

function greaterThan(n) {
return m => m > n;
}
let greaterThan10 = greaterThan(10);
console.log(greaterThan10(12));

How is m assigned the value 12 ? This does'nt give compile time as well as runtime error. Only if i remove m =>, i get an error that m is not defined.

标签: javascriptprogramming-languages

解决方案


推荐阅读