When using Object.getOwnPropertyNames(window), the setTimeout function is not included in the resulting array

The issue at hand is that when using

Object.getOwnPropertyNames(window)
, the setTimeout value is not included in the returned array.

Why is this happening?

In an attempt to further investigate, I tried checking the property descriptor object of the setTimeout property by using

Object.getOwnPropertyDescriptor(window,"setTimeout")
, but it returned undefined.

var windowProp = Object.getOwnPropertyNames(window);

for(var i=0; i< windowProp.length; i++){
    console.log(windowProp[i]);}
// The setTimeout value does not appear in the console output

Object.getOwnPropertyDescriptor(window,"setTimeout")
// Returns undefined

Answer №1

That is because the function setTimeout is not included in that list.

In Chrome, on this page, I see:

Date
EventEmitter
RegExp
adzerk2_inline_ly45m8gua792qbvm
careers_adselector
moveScroller
Function
encodeURIComponent
TypeError
ados_loadFIframe
_gat
careers_cssurl
PR_SHOULD_USE_CONTINUATION
decodeURIComponent
Number
i
sanitizeAndSplitTags
adFeedbackCastVote
adzerk2_html_rpcn4bbtg94kbrvw
genuwine
ados
Boolean
azScriptExtensionLoad
quantserve
eval
StackExchange
PR
isNaN
Array
styleCode
CTIsPlayback
unescape
external
zshow
tagRendererRaw
cssLinkLoad
apiCallbacks
Markdown
scriptSrc
NaN
escape
RangeError
adzerk2_func_fi5lor1t31ib0xu6
v8Intl
careers_leaderboardcssurl
azInitExtension
Object
EvalError
URIError
_gaq
parseFloat
isFinite
careers_companycssurl
uh
gauth
adzerk2_func_d1qd3ryzl0aanl1m
azScriptSRCLoad
_qevents
document
azLoad
decodeURI
__qc
windowProp
tagRenderer
undefined
prettyPrintOne
azHtmlLoad
azScriptInlineLoad
votesCast
SyntaxError
initFadingHelpText
Generator
showFadingHelpText
careers_adurl
jQuery
Infinity
String
prettyPrint
top
zItems
parseInt
JSON
WinterBash
azRegisterExtension
ReferenceError
cssLoad
Math
profileLink
encodeURI
window
Error
location
prepareEditor
initTagRenderer
gaGlobal
chrome
$
ados_frameLoaded
...
function to display the list of properties associated with Window.prototype instead:</p>

<pre><code>var windowProp = Object.getOwnPropertyNames(Window.prototype);

for(var i=0; i< windowProp.length; i++){
console.log(windowProp[i]);}

Object.getOwnPropertyDescriptor(Window.prototype,"setTimeout")
//object

This returns:

toString
webkitPostMessage
postMessage
close
blur
focus
ondeviceorientation
onwebkittransitionend
... // (Truncated for brevity)
btoa
addEventListener
removeEventListener
captureEvents
releaseEvents
getComputedStyle
getMatchedCSSRules
webkitConvertPointFromPageToNode
... // (Truncated for brevity)
constructor
Object

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Preserve menu settings by utilizing local storage

I have been working on saving the state of my menu using localstorage. The jQuery code below is what I am currently using to toggle my menu: <nav id="sidebar" class="active"> <ul class="menu"> <li> <a href="#">Customer ...

Navigating through Objects in Angular 9

I am facing a challenge in Angular 9/Typescript while trying to iterate through the object response from my JSON data. Despite searching for solutions, I haven't found any that work for me. In my JSON, there is a section called "details" which contain ...

Retrieve the data attribute associated with the chosen dropdown selections

I'm currently facing an issue with assigning a custom data attribute to a select box option and then transferring that value to a hidden form field. Here is the HTML I am working with: <select id="sampleorder" multiple="multiple"> <option ...

Spotlight the flaw in the card's backbone using JS

What's the most effective method for emphasizing an error card view in backbone? Initially, I render 10 cards as UI where users input details in each card. Upon clicking submit, I validate all the details by parsing through collection->models. Curr ...

Encountering a FirebaseAuthError while attempting to retrieve a token with Nookies in a NextJS application

In order to validate the successful completion of the registration process for a user, I am attempting to retrieve the user's token from cookies. The code snippet below outlines my approach: [...] export async function getServerSideProps(ctx) { ...

When a dropdown replaces the value of another

I'm currently working on a page using JavaScript, React, and Formik. I have encountered an issue with two dropdowns within one form - when I select a value in one dropdown, the value in the other resets. To illustrate this problem, I have included a g ...

Unexpected behavior: jQuery events failing to execute while triggering the 'change' event with fireEvent

Issue seen in IE7-8. Here's a simple illustration: <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script type="text/javas ...

Searching for a specific string within an array of structured objects: a step-by-step guide

Consider the following scenario: let distinctValues = []; distinctValues.push("ValueA"); distinctValues.push("ValueB"); let firstValue = distinctValues[0]; let searchResults = []; let gridData = grid.jqGrid('getGridParam', 'data'); ...

The pagination in Laravel Vue is causing a validation error due to an invalid prop type check failing

Recently, I delved into working with Nuxt.js and decided to install the Laravel-Vue-Pagination plugin. However, I encountered an error message in my console system that reads: [Vue warn]: Invalid prop: type check failed for prop "data". Expected Object, ...

When scrolling, a new page loads seamlessly

Recently, I came across a website that has an interesting feature where new content is loaded automatically while scrolling, seamlessly appending to the existing page. What's more fascinating is that not only does the content change, but the URL also ...

The TypeScript datatype 'string | null' cannot be assigned to the datatype 'string'

Within this excerpt, I've encountered the following error: Type 'string | null' cannot be assigned to type 'string'. Type 'null' cannot be assigned to type 'string'. TS2322 async function FetchSpecificCoinBy ...

What is the correct syntax for comparing -1, 0, and 1 in JavaScript?

Is there a way to achieve the functionality of a <=> b in JavaScript? It seems that this operator does not exist. Any suggestions for an equivalent function? Appreciate it, Dorian ...

Getting the value from a label and then setting it as the innerHTML of document.getElementById('label')

I have successfully implemented a JavaScript Google Maps functionality, but now I am facing an issue where I need to retrieve the type of HTML control and set it to JavaScript. Specifically, when attempting to extract the value from lblTitle, it is not f ...

Error: The specified schema for the model "superheroes" is missing and has not been registered. Please ensure the schema is properly defined and registered

After updating my server with nodemon, I encountered the following error: C:\Users\mikae\Desktop\Project\node-express-swig-mongo\node_modules\mongoose\lib\index.js:523 throw new mongoose.Error.MissingSchem ...

I am still receiving an empty dropdown value despite implementing ng-selected

I am having issues with using ng-selected to retrieve the selected value from a dropdown. Instead of displaying the selected value, it appears blank. Here is the code snippet I have tried: <div> <select id="user_org" ng-model="selectedorg.all ...

Creating broken lines with Three.js using BufferGeometry

I find myself in a situation where I need to create a Line with holes, essentially a discontinuous line. This entails my Line being composed of multiple segments that are visually separate but conceptually connected. These segments contain more than just t ...

Ways to display the chosen value based on the item's index using Javascript in Angular

If you want to view the complete code, just click on this link. I have identified the main issue here. Check out the code here: https://stackblitz.com/edit/test-trainin-2?file=src/app/app.component.html The problem is when you interact with the green bal ...

"Triggering ngClick causes ngSrc to update, however, the keydown event handler does not have

Currently, I am developing a dynamic live map application that includes various navigation buttons like pan and zoom. To enable keyboard control, I have implemented a keydown event handler that triggers the same function as the button clicks. Interestingl ...

Obtain an instance of a class within a function that is contained within an instance object in TypeScript/Angular

There is a separate object responsible for managing a specific dialog box in my application. The challenge lies in accessing the instance of the class, even though the functions are self-explanatory. I attempted to use the conventional method of that = thi ...

Different body background color changes every second

I have a function called makeRandColor that generates a random color using RGB and template string literals. However, I am struggling to figure out how to make it work every second. I tried using setInterval but it doesn't seem to be functioning prope ...