당신은 항상 자신의 이름으로 자바 스크립트/커피 스크립트 Object
의 속성에 액세스 할 수 있습니다
# suppose you have an object, that contains your sort functions
sortFunctions =
quickSort: (a, b, cb) -> ...
bubbleSort: (a, b, cb) -> ...
insertionSort: (a, b, cb) -> ...
# you can access those properties of sortFunction
# by using the [] notation
sortFunctionName = req.body.sortValue
sortFunction = sortFunctions[sortFunctionName]
# this might return no value, when 'sortFunctionName' is not present in your object
# you can compensate that by using a default value
sortFunction ?= sortFunctions.quickSort
# now use that function as you would usually do
sortFunction arg1, arg2, (err, data) -> if err ... else ...
도움이 되길 바랍니다.)
감사합니다. I는 "(A, B, CB)를 ->"왼쪽 비록 일부 멀리있는 동안 항상 동일한 인수 .. 기본적 SortFunctions = 퀵 : path.variableName 및 sortFunction ARG1, ARG2 (콜백) - > .... .... – user1969202