Home > Web Front-end > JS Tutorial > body text

How to get all parameters of function call chain in JS

PHPz
Release: 2018-10-15 14:46:33
Original
2242 people have browsed it

This article mainly introduces the method of obtaining all parameters of the function call chain in JS. This article directly gives code examples. Friends in need can refer to

function getCallerArgument(){
  var result = [];
  var slice = Array.prototype.slice;
  var caller = arguments.callee.caller;

  while(caller){
    result = result.concat(slice.call(caller.arguments, 0));
    caller = caller.arguments.callee.caller;
  }
  return result;
};

var a = function(){b('a1','a2')}, 
b = function(){b('b1','b2')},
c= function(){return getCallerArgument()};
c('c1');
Copy after login

[Related tutorial recommendations]

1. JavaScript video tutorial
2. JavaScript online manual
3. bootstrap tutorial

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template