What is the purpose of a plus symbol before a variable?

后端 未结 4 1751
死守一世寂寞
死守一世寂寞 2020-11-22 09:39

this really sounds like a simple question but I had no luck searching. what does the +d in

function addMonths(d, n, keepTime) { 
    if (+d) {
         


        
4条回答
  •  情话喂你
    2020-11-22 10:29

    It is a unary "+" operator which yields a numeric expression. It would be the same as d*1, I believe.

提交回复
热议问题