Create a unique object identifier with javascript

Viewed 4346

The objects I use on the client side need a unique ID. My array of objects is very small, commonly 4 items, not more.

I use this:

export class MyItem {   
    uniqueObjectIdentifier: number;
    constructor(obj) {    
        this.uniqueObjectIdentifier = Math.random();
    }
}

Is there something maybe javascript or angular internal that I can access instead of the handcrafted property?

2 Answers
Related