简体   繁体   中英

Javascript Leading Zero Function as Argument

Exist some way that javascript recognize the leading zero as argument (with the primitive value as number)? I have this code:

 let noLeadinZero = (number) => { return number } console.log('noLeadinZero(00):', noLeadinZero(00)) // 0 console.log('noLeadinZero(000):', noLeadinZero(000)) // 0 console.log('noLeadinZero(0000):', noLeadinZero(0000)) // 0

Exist a way, beside the fact i can put the argument of the call of the function in string, for recognize the leading zeros?

No.

Numbers are just numbers. They don't have formatting.

If you want formatting, use a string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM