Using underscore.js in chrome console

2019-08-21 08:40发布

问题:

I am learning JavaScript and came to a point wherein I have to load underscore.js in the chrome console. I did some search and ended at this stackflow response: How to enable to use underscore in console in Chrome developer tool?

The code snippet provided in the above link works for me. But I could not figure out what does window.R object refer to? Why do I need to include this? Can't I just add the script element and load the underscorejs?

I am referring the below piece of code in the stackoverflow response provided. thanks!

(function () {
  if (typeof window.R === 'undefined') {    
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.src = 'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js';
    document.head.appendChild(s);
    }
}());