checkId(userId: string): Promise<User> {
return userPromise
.then(children => children.find(children => children.id === +userId));
}
In the example code above, the statement of child === +userId is + goes in, but I don't know why + goes in. Please give me an answer.
https://github.com/wikibook/ng2-book/blob/master/router/src/app/auth.service.ts
typescript angular
It is used when converting to the number type in JavaScript.
var stringValue = "12345";
console.log(typeof stringValue);
//output : string
var stringToNumber = +stringValue;
console.log(typeof stringToNumber);
//output : number
var stringToNumber2 = Number(stringValue);
console.log(typeof stringToNumber2);
//output : number
© 2024 OneMinuteCode. All rights reserved.