What is the correct JSDoc syntax for a local variable?

后端 未结 4 1383
面向向阳花
面向向阳花 2021-02-18 15:10

For a function like this...

function example() {
  var X = 100;

  ...

  var Y = \'abc\';

  ...

  return Z;
}

I need to explain the purpose

4条回答
  •  猫巷女王i
    2021-02-18 15:54

    I usually use something like the code below in my projects.

    function example() {
      /**
       * Need to explain the purpose of X here.
       * @type {number}
       */
      var X = 100;
    
      ...
    
      /**
       * Need to explain the purpose of Y here.
       * @type {string}
       */
      var Y = 'abc';
    
      ...
    
      return Z;
    }
    

提交回复
热议问题