-
-
Save jeijei4/6855745f9d645f0e8c7a1ed16da198f1 to your computer and use it in GitHub Desktop.
Ejecutar una función con un nombre dado || Run a function with a given name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function login(a, b) { | |
console.log("login " + a + b); | |
} | |
function logout(a) { | |
console.log("logout " + a); | |
} | |
function display(a) { | |
console.log("display " + a); | |
} | |
var funcs = { login: login, logout: logout, display: display }; | |
function run(a, b) { | |
for ( | |
var h = 2, d = arguments.length, f = Array(h < d ? d - h : 0), g = h; | |
g < d; | |
g++ | |
) | |
f[g - h] = arguments[g]; | |
a[b].apply(a, f); | |
} | |
run(funcs, "login", 10, 20), run(funcs, "logout", "the system"), run(funcs, "display", "the movie"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment