E
E
Egor Razinsky2020-04-26 17:26:23
JavaScript
Egor Razinsky, 2020-04-26 17:26:23

Why js throws an error, but at the same time quietly displays the necessary data?

var dat = JSON.parse(datadel);
  var lbls = new Array();
  for (var i = 0; i<= dat.length; i++) {
    lbls[i] = dat[i]['name'];
    console.log(lbls[i]);
  }

During the execution of the code, it is executed, 5ea599de244d0778241650.pngbut it throws a TypeError error, which breaks the further execution of the code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-04-26
@destkoder

Because dat[dat.length] doesn't exist and you're trying to output it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question