To simplify access to Liquid Objects it can be helpful to construct JS object to hold values
Doing this inside your product templates creates an object that you can fill with whatever information you want that pertains to the variants of your product:
<script>
var customVariantObject = {};
﹛% for var in product.variants %﹜
customVariantObject[﹛﹛- var.id -﹜﹜] = {
inventoryQuantity : ﹛﹛ var.inventory_quantity | default: 0 ﹜﹜,
available : ﹛﹛ var.available ﹜﹜,
inventoryManagement : “﹛﹛ var.inventory_management ﹜﹜”,
inventoryPolicy : “﹛﹛ var.inventory_policy | default: “deny”﹜﹜”
};
﹛% endfor %﹜
</script>﹛
Watch Seán's video for more details about this approach