Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

js中传参的形式是什么?

        function test(para) {
            para = {};
        }
        var obj = {
            a : 123,
            b : 3456
        }
        test(obj);
        console.log(obj);

image.png
这个函数为什么不会改变obj呢?
js中针对引用值不是引用传递吗?(我理解的是:引用变量就相当于C中的指针。)


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

1 Answer

0 votes
by (71.8m points)

JS 哪来的引用传递,全都是值传递。

你这是把 按引用传递参数传递的参数是引用类型 弄混了,完全不是一个意思。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...