JavaScript ternary operator calling function or no-op - Stack Overflow

What is best practice for debugging in JavaScript?debugging ? console.log('info') : null;My q

What is best practice for debugging in JavaScript?

debugging ? console.log('info') : null;

My question is the null, what is standard practice for this in general, or in this debugging use case?

What is best practice for debugging in JavaScript?

debugging ? console.log('info') : null;

My question is the null, what is standard practice for this in general, or in this debugging use case?

Share Improve this question edited Apr 19, 2015 at 12:46 php-dev 7,1764 gold badges26 silver badges38 bronze badges asked Apr 19, 2015 at 12:03 Mark RobbinsMark Robbins 2,4575 gold badges24 silver badges34 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 13

In your case:

debugging && console.log('info');

This trick is based on the "short circuit" feature and I suppose this info might be useful: http://en.wikipedia/wiki/Short-circuit_evaluation

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744563460a4581020.html

相关推荐

  • JavaScript ternary operator calling function or no-op - Stack Overflow

    What is best practice for debugging in JavaScript?debugging ? console.log('info') : null;My q

    2天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信