I don't understand function return in javascript

前端 未结 3 1211
日久生厌
日久生厌 2021-01-15 08:20

Can anyone explain why javascript return statement is used in function? when and why we should use it?

Please help me.

3条回答
  •  鱼传尺愫
    2021-01-15 09:05

    it's used to return a value from the function.

    Let's say you want a function to do some calculation... for a simple example, like calculate a div box's left position on the browser screen.

    you call the function and give it the html selector, then the function 'returns' you the left position value.

提交回复
热议问题