最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin5浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论