javascript - How to tell whether running in a browser or in NodeJS? -


इस सवाल का पहले से ही एक उत्तर है: < / P>

  • 17 उत्तरों

सबसे अच्छा तरीका क्या है यह एक ब्राउज़र या नोडजेएस में चल रहा है या नहीं यह जानने के लिए जावास्क्रिप्ट कोड है?

मैं ऐसी कोई चीज़ ढूंढ रहा हूं जिसे बूलियन के लिए मूल्यांकन किया जाएगा।

विंडो < / कोड> और अपवाद को पकड़ने के बजाय clinky लगता है क्या कोई बेहतर तरीका है?

आप निम्न के एक कट-डाउन संस्करण का उपयोग कर सकते हैं: < पूर्व> var isNode = (प्रकार का निर्यात === 'ऑब्जेक्ट')? सही गलत;


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -