My main question is, what type of data function parameters is accepting? I would pass a comparison as parameters as for exemple
Function test(a) //where A is a comparison so for example
test("a" == "a")
I'm trying to get the comparison expression and not the result.
Is it something possible? Any way to do it? Thanks
Yes, you can pass functions as parameters, and it's quite a common pattern in both JS and other languages to pass "predicate" functions.
let isGreaterThan5 = v => v > 5; let out = [1,3,5,7,9].filter(isGreaterThan5); console.log(out);
Yes it is possible:
function isPosible(param) { // Here you define a function return param; } // Below you are executing the function and printing the result console.log(isPosible("a === a")); // Returns the whole expression
More important is to understand that you can pass any expression as argument to a function, including but not limited to: Any primitive type (string, number, boolean, undefined, null, etc..), functions (callbacks), expressions that evaluates something like your case .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.