'Why would joining an array work, but not accessing individual elements?
I've just started working on customizing my Shopify template, but I've ran into a basic issue, where the docs didn't help.
<script>console.log("_{{ item.properties | join: ", " }}_");</script>
// prints "_foo1, foo2_"
<script>console.log("_{{ item.properties[0] }}_");</script>
// prints "__"
<script>console.log("_{{ item.properties }}_");</script>
// prints "_EscapedHashDrop_"
Thanks!
Solution 1:[1]
you are getting value in string in first console and try to fetch value as a array in second console so it's not possible
you have to convert your string value in array by using .split() function.
Try this code it will give result according to you.
var itemvalue = "_{{ item.properties | join: ", " }}_";
// console.log(itemvalue); ---> print "_foo1, foo2_"
var myvalue = itemvalue.split(",");
console.log(myvalue[0]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dotsquares |
