How do I delay a function call for 5 seconds?

You can use plain javascript, this will call your_func once, after 5 seconds: If your function has no parameters and no explicit receiver you can call directly setTimeout(func, 5000) There is also a plugin I’ve used once. It has oneTime and everyTime methods. jQuery timers plugin

Is there a standard function to check for null, undefined, or blank variables in JavaScript?

You can just check if the variable has a truthy value or not. That means will evaluate to true if value is not: null undefined NaN empty string (“”) 0 false The above list represents all possible falsy values in ECMA-/Javascript. Find it in the specification at the ToBoolean section. Furthermore, if you do not know whether a variable exists (that means, if it was declared) you should check with the typeof operator. For instance … Read more

What does “export default” do in JSX?

Export like export default HelloWorld; and import, such as import React from ‘react’ are part of the ES6 modules system. A module is a self contained unit that can expose assets to other modules using export, and acquire assets from other modules using import. In your code: In ES6 there are two kinds of exports: Named exports – for example export function func() {} is a named … Read more

How to destroy a JavaScript object?

You could put all of your code under one namespace like this: Using the delete keyword will delete the reference to the property, but on the low level the JavaScript garbage collector (GC) will get more information about which objects to be reclaimed. You could also use Chrome Developer Tools to get a memory profile of your … Read more

How to disable button in React.js

Using refs is not best practice because it reads the DOM directly, it’s better to use React’s state instead. Also, your button doesn’t change because the component is not re-rendered and stays in its initial state. You can use setState together with an onChange event listener to render the component again every time the input field changes: Here’s a working example: