0

Why i cannot add object to the following array?

var userNames = {};
var input = $(this).text();
console.log('input=' + input); //success
userNames.push(input);
1
  • An array initializer looks like this: []. What you've got is an object. Commented Aug 26, 2017 at 13:44

1 Answer 1

1
var userNames = [];
var input = $(this).text();
console.log('input=' + input); //success
userNames.push(input);
Sign up to request clarification or add additional context in comments.

Comments