What does = +_ mean in JavaScript

前端 未结 12 1864
南笙
南笙 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:22

    = +_ will cast _ into a number.

    So

    var _ = "1",
       r = +_;
    console.log(typeof r)
    

    would output number.

提交回复
热议问题