Recently in the implementation of a function, that is to display the resolution of the picture information.

Since resolution is nothing more than a width by height format, like 250×140.

Then I implemented this in my code:

return `${dimension? .width}x${dimension? .height}`;
Copy the code

A Dimension is a resolution object, and it has width and height.

However, one of the big guys found this problem when he reviewed the code to me. He said, “Can you look at how it is expressed in other places? Do you need to do Localization in different regions?”

So I took a look at Chrome and opened a random image:

Isn’t that what it says?

Did I get that right? What went wrong?

When puzzled, he went to the big man for help. The big man said:

Is Chrome using the letter x or are they using the × character?
Copy the code

I suddenly realized that it was the character problem!

Then I tracked down the Chrome page:

Since this information is displayed in the TAB, it must be in the title node. I copied the character and compared it to the letter X:

It wasn’t the letter X, it was the character x. Interesting!

Later I changed it to ×, and the modification is as follows:

return `${dimension? .width}x${dimension? .height}`;
Copy the code

Then told the big guy, the big guy smiled happily and said:

Nice, no localization necessary =)
Copy the code

Wonderful!

Ha ha, here is a simple record, very interesting, otherwise I always thought it was a letter X.

The standard way to express resolution in the future is to use a character x instead of a letter x, for example:

250x160  
Copy the code

Instead of:

250x160
Copy the code

It’s up!

Eggs: my WeChat nickname actually have similar characters, such as “Cui Qingcai 丨 static find” is the “丨” in the middle of a Chinese character (pronounced for gnu), rather than the vertical bar “|”, ha, ha, ha.

For more exciting content, please pay attention to my public account “Attack Coder” and “Cui Qingcai | Jingmi”.