How to access an element of an array without using indexer (javascript)? -
let's have single element array ["somestringhere"]
(i don't know in advance string be) , want access string function returns string , not array, how without using indexer (ex: array[0])?
in other words, if delete brackets had string.
every object has tostring
method. go using method, though it's confusing why you'd want to. option join
method.
var somearr = ['some string here']; console.log(somearr.tostring()); console.log(somearr.join());
according mdn:
the array object overrides tostring method of object. array objects, tostring method joins array , returns 1 string containing each array element separated commas.
see here specifics.
Comments
Post a Comment