Expression selector
Learn how to get values using dynamic expressions.
The expression selector is the most versatile, as it allows you to use any expression to access a property or an item in a list.
This selector is especially useful when the property name is not a valid identifier or when you want to dynamically compute the index or key.
For example, say you want to get the value of a query string parameter named referral code. Because the property name contains spaces, you can only access it using the expression selector:
page.query['referral code']
Because you can use any expression, you could store the property name in a variable and use it in the expression:
let param = 'referral code';page.query[param]
You can also use numeric indexes to access items in a list:
let transport = ["🚀", "🚗", "🚆"];transport[0] // 🚀
Notice that the index is zero-based, so the first item has an index of 0, the second item has an index of 1, and so on. For a more natural way to access items in a list, see the ordinal selector.