A method, such as sum (int a,int b,int c) {return a+b+c;}, on the server to calculate the good or the browser JS to calculate it?

Source: Internet
Author: User
I personally tend to put in the browser JS to calculate, but there is no strong reason.
Do not involve security and store this data.
A,b,c and A.B.C are just used to show up on the page.

Reply content:

Word: On the client or server side is primarily security -related. Because the client's data can be forged.
advantages of placing on the client :
  1. Reduce server pressure
  2. Reduce broadband occupancy (only one value is passed)
Disadvantages:
  1. Need to verify its validity
Summarize:
If the number is not important, put it on the client side. If important can also be placed on the client, but need to have a validation mechanism, it is recommended to put on the server side. If this is a function of calculating the blood drop when the enemy hits you, it should be put on the server to calculate, otherwise it will be cheated. Of course the client computed it.

Such a function does not need to change the server state, there is no need to go to server computing. Must put the server Ah, the CPU must run until the end of 100% to rent an object home for the new year AH should be put on the client
The first floor is right, it's about security.
Here your code, do not need to be stored in the database, and do not need to read the server resources, itself where the execution of the server data status will not affect
In this case, put on the server side, there is no benefit, can be done on the client side of the client to complete this is not a performance cost problem, but based on this calculation is used to solve what problem. If it is to calculate a sum on the browser side, but do not need to verify or save parameters, results, then why should be placed on the server. Put to the browser JS to calculate, promote webapp and HTML5 development, for human contribution. Ha ha
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.