What does = +_ mean in JavaScript

前端 未结 12 1938
南笙
南笙 2020-11-22 11:37

I was wondering what the = +_ operator means in JavaScript. It looks like it does assignments.

Example:

hexbin.radius = function(_)         


        
12条回答
  •  佛祖请我去吃肉
    2020-11-22 12:18

    It is not an assignment operator.

    • _ is just a parameter passed to the function.

      hexbin.radius = function(_) {
                      //       ^ It is passed here
          // ...
      };
      
    • On the next line r = +_; + infront casts that variable (_) to a number or integer value and assigns it to variable r

    DO NOT CONFUSE IT WITH += operator

提交回复
热议问题