A very common piece of JS code, but there is a very strange problem.

The

code is as follows. Anchor is a map structure. If you get an element in anchor according to id, there is no problem printing anchor.get (id), but getting attributes in anchor.get (id) is empty, which makes me do not understand

.
    function sendLiveOffer(id) {
        console.log(id)
        console.log(anchor.get(id))
        console.log(anchor.get(id).localDescription)
        let sdp = anchor.get(id).localDescription
        let offer = {
            name: "anchor",
            target: id,
            type: "video-offer",
            sdp: sdp
        }
        console.log("offer ")
    }

Mar.01,2021

you won't be confused if you know that the object is a reference type.

give you a piece of code reference, but there's nothing you can do if you don't understand it:


 let info = anchor.get(id);
 let desc = info.localDescription;

can you give me a guide?

Menu