Guest User

Untitled

a guest
Jul 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function (obj) {
  2. var out, l1, stack, fetch, escape, isFunction;
  3. out = [];
  4. stack = [];
  5. stack.push(obj);
  6. fetch = function fetch(key) {
  7. var i, v;
  8. for (i = stack.length - 1; i >= 0; i -= 1) {
  9. v = stack[i][key];
  10. if (v) {
  11. return v;
  12. }
  13. }
  14. };
  15. escape = function escape(value) {
  16. return ('' + value)
  17. .replace(/&/g, '&')
  18. .replace(/</g, '<')
  19. .replace(/>/g, '>')
  20. .replace(/"/g, '"');
  21. };
  22. isFunction = function isFunction(obj) {
  23. return !!(obj && obj.constructor && obj.call && obj.apply);
  24. };
  25. out.push("Hello ");
  26. l1 = fetch("planet");
  27. if (isFunction(l1)) {
  28. l1 = l1();
  29. }
  30. out.push(escape(l1));
  31. return out.join("");
  32. }
Add Comment
Please, Sign In to add comment