How do I access an element of an array returned by a function in javascript?
So I have a function
function getArray(){
return ["a", "b", "c"];
}
and I would like to access one of the elements without having to assign
the return to a variable, like so:
if(true)
if(false || true)
console.log(getArray()[0]);
This is a syntax error, along with .0. I noticed there is no "at" method
and my code uses enough for-in loops that I can't pollute the array object
with a prototype function.
So any ideas? (Yes I am simply trying to avoid curly braces. It is a style
choice.)
No comments:
Post a Comment