In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "what are the differences between Js value transmission and reference transmission". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Different concepts
1. The value is passed one-way, which can only be passed from the argument to the parameter, and the parameter cannot change the value of the parameter.
2. The passing of reference type can change the actual parameter by changing the parameter. As long as any variable points to the same space, the variable can manipulate the value of that space.
The type of data passed
3. Value transfer passes a value. Reference passing is passing an object.
(1) value transfer
Var a = 1 fn function fn (a) {a + +; return a;} a = 1 position console.log (fn (a)); console.log (a)
(2) reference transfer
Var obj = {name: "abc",} function fn (obj) {Orville's Ideas and Interests = "abc"; / / points to the object created outside the function obj = new Object (); / / creates a brand new object that does not point to the externally created object Orville's Ideas and Interests = "123"; / / adds attributes to the newly created object} var obj = new Object (); fn (obj); console.log (Orville's Ideas and Interests) / / obj is an externally created object, so the output value is "abc"what are the differences between Js value passing and reference passing". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.