Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,026 questions

51,982 answers

573 users

How to display the global window object information with this in JavaScript

1 Answer

0 votes
console.log(this);

  
    
    

// run:
    
[object Window] {
  addEventListener: function addEventListener() {
    [native code]
},
  alert: function alert() {
    [native code]
},
  applicationCache: [object OfflineResourceList] {
    addEventListener: function addEventListener() {
      [native code]
},
    CHECKING: 2,
    dispatchEvent: function dispatchEvent() {
      [native code]
},
    DOWNLOADING: 3,
    IDLE: 1,
    length: 0,
    mozAdd: function mozAdd() {
      [native code]
},
    mozHasItem: function mozHasItem() {
      [native code]
},
    mozItem: function mozItem() {
      [native code]
},
    mozRemove: function mozRemove() {
      [native code]
},
    OBSOLETE: 5,
    oncached: null,
    onchecking: null,
    ondownloading: null,
    onerror: null,
    onnoupdate: null,
    onobsolete: null,
    onprogress: null,
    onupdateready: null,
    removeEventListener: function removeEventListener() {
      [native code]
},
    status: 0,
    swapCache: function swapCache() {
      [native code]
},
    UNCACHED: 0,
    update: function update() {
      [native code]
},
    UPDATEREADY: 4
  },
  atob: function atob() {
    [native code]
},
  blur: function blur() {
    [native code]
},
  btoa: function btoa() {
    [native code]
},
  caches: [object CacheStorage] {
    delete: function delete() {
      [native code]
},
    has: function has() {
      [native code]
},
    keys: function keys() {
      [native code]
},
    match: function match() {
      [native code]
},
    open: function open() {
      [native code]
}
  },
  cancelAnimationFrame: function cancelAnimationFrame() {
    [native code]
},
  cancelIdleCallback: function cancelIdleCallback() {
    [native code]
},
  captureEvents: function captureEvents() {
    [native code]
},
  clearInterval: function clearInterval() {
    [native code]
},
  clearTimeout: function clearTimeout() {
    [native code]
},
  close: function close() {
    [native code]
},
  closed: false,
  confirm: function confirm() {
    [native code]
},
  createImageBitmap: function createImageBitmap() {
    [native code]
},
  crossOriginIsolated: false,
  crypto: [object Crypto] {
    getRandomValues: function getRandomValues() {
      [native code]
},
    subtle: [object SubtleCrypto] { ... }
  },
  customElements: [object CustomElementRegistry] {
    define: function define() {
      [native code]
},
    get: function get() {
      [native code]
},
    upgrade: function upgrade() {
      [native code]
},
    whenDefined: function whenDefined() {
      [native code]
}
  },
  devicePixelRatio: 1.0909090909090908,
  dispatchEvent: function dispatchEvent() {
    [native code]
},
  document: [object HTMLDocument] {
    activeElement: [object HTMLBodyElement] { ... },
    addEventListener: function addEventListener() {
      [native code]
},
    adoptNode: function adoptNode() {
      [native code]
},
    alinkColor: "",
    all: undefined,
    anchors: [object HTMLCollection] { ... },
    append: function append() {
      [native code]
},
    appendChild: function appendChild() {
      [native code]
},
    applets: [object HTMLCollection] { ... },
    ATTRIBUTE_NODE: 2,
    baseURI: "https://fiddle.jshell.net/_display/?editor_console=true",
    bgColor: "",
    body: [circular object HTMLBodyElement] :
<body>
        
    
        <script type="text/javascript">//<![CDATA[
    
    
    console.log(this);
    
      
        
        
    /*
    run:
        
    true
    true
    true
    false
    "c++"
    "javascript"
    "javascript"
    false
    ""
        
    */
    
      
    
    
    
      //]]></script></body>,
    captureEvents: function captureEvents() {
      [native code]
},
    caretPositionFromPoint: function caretPositionFromPoint() {
      [native code]
},
    CDATA_SECTION_NODE: 4,
    characterSet: "UTF-8",
    charset: "UTF-8",
    childElementCount: 1,
    childNodes: [object NodeList] { ... },
    children: [object HTMLCollection] { ... },
    clear: function clear() {
      [native code]
},
    cloneNode: function cloneNode() {
      [native code]
},
    close: function close() {
      [native code]
},
    COMMENT_NODE: 8,
    compareDocumentPosition: function compareDocumentPosition() {
      [native code]
},
    compatMode: "CSS1Compat",
    contains: function contains() {
      [native code]
},
    contentType: "text/html",
    createAttribute: function createAttribute() {
      [native code]
},
    createAttributeNS: function createAttributeNS() {
      [native code]
},
    createCDATASection: function createCDATASection() {
      [native code]
},
    createComment: function createComment() {
      [native code]
},
    createDocumentFragment: function createDocumentFragment() {
      [native code]
},
    createElement: function createElement() {
      [native code]
},
    createElementNS: function createElementNS() {
      [native code]
},
    createEvent: function createEvent() {
      [native code]
},
    createExpression: function createExpression() {
      [native code]
},
    createNodeIterator: function createNodeIterator() {
      [native code]
},
    createNSResolver: function createNSResolver() {
      [native code]
},
    createProcessingInstruction: function createProcessingInstruction() {
      [native code]
},
    createRange: function createRange() {
      [native code]
},
    createTextNode: function createTextNode() {
      [native code]
},
    createTreeWalker: function createTreeWalker() {
      [native code]
},
    currentScript: [object HTMLScriptElement] { ... },
    defaultView: [circular object Window],
    designMode: "off",
    dir: "",
    dispatchEvent: function dispatchEvent() {
      [native code]
},
    doctype: [object DocumentType] { ... },
    DOCUMENT_FRAGMENT_NODE: 11,
    DOCUMENT_NODE: 9,
    DOCUMENT_POSITION_CONTAINED_BY: 16,
    DOCUMENT_POSITION_CONTAINS: 8,
    DOCUMENT_POSITION_DISCONNECTED: 1,
    DOCUMENT_POSITION_FOLLOWING: 4,
    DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32,
    DOCUMENT_POSITION_PRECEDING: 2,
    DOCUMENT_TYPE_NODE: 10,
    documentElement: [object HTMLHtmlElement] { ... },
    documentURI: "https://fiddle.jshell.net/_display/?editor_console=true",
    domain: "fiddle.jshell.net",
    ELEMENT_NODE: 1,
    elementFromPoint: function elementFromPoint() {
      [native code]
},
    elementsFromPoint: function elementsFromPoint() {
      [native code]
},
    embeds: [object HTMLCollection] { ... },
    enableStyleSheetsForSet: function enableStyleSheetsForSet() {
      [native code]
},
    ENTITY_NODE: 6,
    ENTITY_REFERENCE_NODE: 5,
    evaluate: function evaluate() {
      [native code]
},
    execCommand: function execCommand() {
      [native code]
},
    exitFullscreen: function exitFullscreen() {
      [native code]
},
    exitPointerLock: function exitPointerLock() {
      [native code]
},
    fgColor: "",
    firstChild: [circular object DocumentType],
    firstElementChild: [circular object HTMLHtmlElement] :
    
            w.onerror = (message, url, line, column) => {
              // the line needs to correspond with the editor panel
              // unfortunately this number needs to be altered every time this view is changed
              line = line - 70
              if (line < 0){
                pushToConsole(message, "error")
              } else {
                pushToConsole(`[${line}:${column}] ${message}`, "error")
              }
            }
    
            let console = (function(systemConsole){
              return {
                log: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "log")
                  systemConsole.log.apply(this, args)
                },
                info: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "info")
                  systemConsole.info.apply(this, args)
                },
                warn: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "warn")
                  systemConsole.warn.apply(this, args)
                },
                error: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "error")
                  systemConsole.error.apply(this, args)
                },
                system: function(arg){
                  pushToConsole(arg, "system")
                },
                clear: function(){
                  systemConsole.clear.apply(this, {})
                },
                time: function(){
                  let args = Array.from(arguments)
                  systemConsole.time.apply(this, args)
                },
                assert: function(assertion, label){
                  if (!assertion){
                    pushToConsole(label, "log")
                  }
    
                  let args = Array.from(arguments)
                  systemConsole.assert.apply(this, args)
                }
              }
            }(window.console))
    
            window.console = { ...window.console, ...console }
    
            console.system("Running fiddle")
          }
    
          if (window.parent){
            customConsole(window)
          }
        </script>
    </head>
    <body>
        
    
        <script type="text/javascript">//<![CDATA[
    
    
    console.log(this);
    
      
        
        
    /*
    run:
        
    true
    true
    true
    false
    "c++"
    "javascript"
    "javascript"
    false
    ""
        
    */
    
      
    
    
    
      //]]></script></body></html>,
    fonts: [object FontFaceSet] { ... },
    forms: [object HTMLCollection] { ... },
    fullscreen: false,
    fullscreenElement: null,
    fullscreenEnabled: true,
    getAnimations: function getAnimations() {
      [native code]
},
    getElementById: function getElementById() {
      [native code]
},
    getElementsByClassName: function getElementsByClassName() {
      [native code]
},
    getElementsByName: function getElementsByName() {
      [native code]
},
    getElementsByTagName: function getElementsByTagName() {
      [native code]
},
    getElementsByTagNameNS: function getElementsByTagNameNS() {
      [native code]
},
    getRootNode: function getRootNode() {
      [native code]
},
    getSelection: function getSelection() {
      [native code]
},
    hasChildNodes: function hasChildNodes() {
      [native code]
},
    hasFocus: function hasFocus() {
      [native code]
},
    hasStorageAccess: function hasStorageAccess() {
      [native code]
},
    head: [object HTMLHeadElement] { ... },
    hidden: false,
    images: [object HTMLCollection] { ... },
    implementation: [object DOMImplementation] { ... },
    importNode: function importNode() {
      [native code]
},
    inputEncoding: "UTF-8",
    insertBefore: function insertBefore() {
      [native code]
},
    isConnected: true,
    isDefaultNamespace: function isDefaultNamespace() {
      [native code]
},
    isEqualNode: function isEqualNode() {
      [native code]
},
    isSameNode: function isSameNode() {
      [native code]
},
    lastChild: [circular object HTMLHtmlElement] :
    
            w.onerror = (message, url, line, column) => {
              // the line needs to correspond with the editor panel
              // unfortunately this number needs to be altered every time this view is changed
              line = line - 70
              if (line < 0){
                pushToConsole(message, "error")
              } else {
                pushToConsole(`[${line}:${column}] ${message}`, "error")
              }
            }
    
            let console = (function(systemConsole){
              return {
                log: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "log")
                  systemConsole.log.apply(this, args)
                },
                info: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "info")
                  systemConsole.info.apply(this, args)
                },
                warn: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "warn")
                  systemConsole.warn.apply(this, args)
                },
                error: function(){
                  let args = Array.from(arguments)
                  pushToConsole(args, "error")
                  systemConsole.error.apply(this, args)
                },
                system: function(arg){
                  pushToConsole(arg, "system")
                },
                clear: function(){
                  systemConsole.clear.apply(this, {})
                },
                time: function(){
                  let args = Array.from(arguments)
                  systemConsole.time.apply(this, args)
                },
                assert: function(assertion, label){
                  if (!assertion){
                    pushToConsole(label, "log")
                  }
    
                  let args = Array.from(arguments)
                  systemConsole.assert.apply(this, args)
                }
              }
            }(window.console))
    
            window.console = { ...window.console, ...console }
    
            console.system("Running fiddle")
          }
    
          if (window.parent){
            customConsole(window)
          }
        </script>
    </head>
    <body>
        
    
        <script type="text/javascript">//<![CDATA[
    
    
    console.log(this);
    
      
        
        
    /*
    run:
        
    true
    true
    true
    false
    "c++"
    "javascript"
    "javascript"
    false
    ""
        
    */
    
 
    ongotpointercapture: null,
    oninput: null,
    oninvalid: null,
    onkeydown: null,
    onkeypress: null,
    onkeyup: null,
    onload: null,
    onloadeddata: null,
    onloadedmetadata: null,
    onloadend: null,
    onloadstart: null,
    onlostpointercapture: null,
    onmousedown: null,
    onmouseenter: null,
    onmouseleave: null,
    onmousemove: null,
    onmouseout: null,
    onmouseover: null,
    onmouseup: null,
    onmozfullscreenchange: null,
    onmozfullscreenerror: null,
    onpaste: null,
    onpause: null,
    onplay: null,
    onplaying: null,
    onpointercancel: null,
    onpointerdown: null,
    onpointerenter: null,
    onpointerleave: null,
    onpointerlockchange: null,
    onpointerlockerror: null,
    onpointermove: null,
    onpointerout: null,
    onpointerover: null,
    onpointerup: null,
    onprogress: null,
    onratechange: null,
    onreadystatechange: null,
    onreset: null,
    onresize: null,
    onscroll: null,
    onseeked: null,
    onseeking: null,
    onselect: null,
    onselectionchange: null,
    onselectstart: null,
    onstalled: null,
    onsubmit: null,
    onsuspend: null,
    ontimeupdate: null,
    ontoggle: null,
    ontransitioncancel: null,
    ontransitionend: null,
    ontransitionrun: null,
    ontransitionstart: null,
    onvisibilitychange: null,
    onvolumechange: null,
    onwaiting: null,
    onwebkitanimationend: null,
    onwebkitanimationiteration: null,
    onwebkitanimationstart: null,
    onwebkittransitionend: null,

    ... 
  

 



answered May 23, 2021 by avibootz
edited May 23, 2021 by avibootz
...