简体   繁体   中英

JavaScript object value returns undefined

I assigned a number (audio duration) to a property of an object.

data[i]["audio-duration"] = data[i].audio.duration;

When I console log that object, the audio-duration property shows correctly like:

audio: audio
audio-connection: "2D2NLN7KpO"
audio-duration: 121.99425
audio-name: "Rain Pure"
audio-note: ""
audio-path: "rain.mp3"

But whenever I try to get the audio-duration property like this:

let timelineData = data;
console.log(timelineData[i]["audio-duration"]);

It always returns undefined .

Can anyone help me with this?

The property to use is audioelement.duration and not audioelement.ausio.duration to get audio duration.

Refer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM