This is perhaps a silly question but I couldn't find an explanation anywhere else.
In the Angular official tutorial of routing, the following array is provided:
export const products = [
{
name: 'Phone XL',
price: 799,
description: 'A large phone with one of the best screens'
},
{
name: 'Phone Mini',
price: 699,
description: 'A great phone with one of the best cameras'
},
{
name: 'Phone Standard',
price: 299,
description: ''
}
];
In the routing section, when displaying a single product details, the following syntax is used to get the current product index through the URL:
this.product = products[+params.get('protectId')];
I noticed that without the '+'
, the params return null. Could anyone explain to me whats the purpose of the +
?