Home  >  Article  >  Web Front-end  >  Limitations of js itself: don’t let javascript do too many things_javascript skills

Limitations of js itself: don’t let javascript do too many things_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:31:291126browse

Someone even asked me, "There are 5 text boxes on the page. Each text box can only input one character. How can I use js to automatically jump to the second text box after the user inputs the focus."

I said, shouldn’t this function be done by Tab? After the user inputs, he only needs to press the Tab key. Moreover, the user can also control whether to switch to the next one (because the user may also make an input error).

But he persisted, saying that it was the boss who asked for it. I finally had to help him implement this function. But it just feels weird.


When I first learned to use js, I felt that js was so magical. It could make some very complex functions simple and easy. Later, I gradually learned that there are many things that js cannot do, such as operating client files, etc.

At that time, I often complained about why js could not realize functions that could be realized by other languages, so I did a lot of things that js should not do.

Once, in order to read a resource file, I wrote hundreds of lines of code in js. As a result, I only read one line of content in xml. Later, when I went back to modify it, I found that the code I wrote before used It can be implemented in vb.net or C# in no more than 5 lines.


I think js should not do too many additional events. One of the reasons is the limitations of js itself - js is run on the client, and all codes are sent to the client machine for execution. As a result, some logic such as encrypting user data should not be implemented in js.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn