Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

javascript如何在函数内部获取传入函数的实参名

比如:

const test = '123';
const typeIs = data => {
    console.log();
    return toString.call(data).replace(/object|[|]|s/g, '').toLowerCase();
};

typeIs(test);

应该在console.log里面怎么写,才能打印出传入typeIs这个函数的实参名字:'test'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

不能。

JS 里没有类似反射的机制来获取执行上下文。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...