Unary Operator
String to number conversion using the unary operator. const a = '10'; +a // will print number 10 Look at below const foo = { valueOf: () => '10' }; +foo // it will also print 10
Search for a command to run...
String to number conversion using the unary operator. const a = '10'; +a // will print number 10 Look at below const foo = { valueOf: () => '10' }; +foo // it will also print 10
Readonly<Type> It will set all the properties of Type to read-only, which means the properties of the Type cannot be reassigned. Let's see with an example so that we can understand easily interface Person { name: string, age: number } let pe...
The map is a collection of key-value pairs like Objects. But the main difference is map allows keys of any type(primitive/non-primitive). When we try to store an object as a key in Object, it converts all keys to strings and the resulted value would ...
function sortNumbers() { return arr.reduce((acc, value) => { const nextIndex = acc.findIndex(num => value > num); const index = nextIndex > -1 ? nextIndex : acc.length; acc.splice(index, 0, value); return acc; ...