<input type="text" id="blah" value="'a1','a2'">
<script>
dd=document.getElementById('blah').value
cars = [dd]
console.log(cars)
</script>
When I try to do it in console I see the result:
[‘"a1", "a2"’]
This is why I can’t use it as array.
What I want is:
["a1","a2"]
I want to use it as array. How can I do it? Is it possible?
>Solution :
<input type="text" id="blah" value="'a1','a2'">
<script>
dd=document.getElementById('blah').value
cars = dd.split(',').map(e=>e.substr(1, e.length-2));
console.log(cars)
</script>