Uncaught TypeError: (intermediate value)(...) is not a function
The error is a result of the missing semicolon on the third line:
window.Glog = function(msg) {
console.log(msg);
}; // <--- Add this semicolon
(function(win) {
// ...
})(window);
The ECMAScript specification has specific rules for automatic semicolon insertion, however in this case a semicolon isn't automatically inserted because the parenthesised expression that begins on the next line can be interpreted as an argument list for a function call.
This means that without that semicolon, the anonymous window.Glog
function was being invoked with a function as the msg
parameter, followed by (window)
which was subsequently attempting to invoke whatever was returned.
This is how the code was being interpreted:
window.Glog = function(msg) {
console.log(msg);
}(function(win) {
// ...
})(window);
Uncaught TypeError: (intermediate value)(…) is not a function, putting semicolon like I've read online is not working
You must do export default makePage;
without the (). Using export default makePage();
exports makePage
function returns that is undefined. So Try this:
function makeBackground() {
const background = document.createElement('div');
background.classList.add("background");
document.body.appendChild(background);
}
function navBar() {
const content = document.querySelector('#content');
const header = document.createElement('header');
const ul = document.createElement("ul");
const nav = document.createElement('nav');
content.append(header);
header.append(nav);
nav.append(ul);
const home = document.createElement('li');
home.setAttribute("id", 'home');
home.textContent = "Home";
ul.append(home);
const menu = document.createElement("li");
menu.setAttribute('id', 'menu');
menu.textContent = "Menu";
ul.append(menu);
const contact = document.createElement('li');
contact.setAttribute('id', 'contact');
contact.textContent = "Contact";
ul.append(contact);
}
function makePage() {
makeBackground();
navBar();
}
export default makePage;
TypeError: (intermediate value)(intermediate value)(intermediate value) is not iterable
looking at this code:
const [startDate, endDate] = filterValues?.dateRange
filterValues
can be potentially undefined
(looking at the optional chaining operator). You cannot destruct array value from undefined
if you put this in a browser console:
const filterValues = undefined
const [startDate, endDate] = filterValues?.dateRange
you will get the exact same error:
VM291:1 Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at :1:30
You need to either fallback to an empty array:
const [startDate, endDate] = filterValues?.dateRange ?? []
or not use array destructuring:
const dateRange = filterValues?.dateRange
const startDate = dateRange?.[0]
const endDate = dateRange?.[1]
TypeError: (intermediate value).parseFromString(...).replace is not a function
You are treating a DOMParser object as a string. That will not work.
You need to do something like this since it is not recommended you change valid HTML before parsing it
const html = `<html><div aria-expanded="false"></div></html>`
const parsedHTML = new DOMParser().parseFromString(html, "text/html");
parsedHTML.querySelector("div").setAttribute("aria-expanded",true)
console.log(parsedHTML.querySelector("div"));
Related Topics
Redirect to Url After Form Submit in React
How to Calculate the Sum of Table Column in Angular 2+
How to Get the Ajax Response from Success and Assign It in a Variable Using Jquery
Angular - How to Get Result of a Json Object
How to Pass Data from Flask to JavaScript in a Template
React Native How to Call Multiple Functions When Onpress Is Clicked
How to Look for Changes in Localstorage in Angular 4
How to Disable and Enable a Click Event on a Table Td
Validation Using Yup to Check String or Number Length
Change Name of Uploaded File on Client
Calculate Total Sum of Dynamically Added Items to a Table
For Loop With Two Array in JavaScript
How to Check a Postal Code in JavaScript
How to Get Dynamically Generated Table Td Input Value
Jquery - Get Id Dynamically from Generated Element
How to Make an Empty String Array in Typescript
How to Run a Program or Batch File on the Client Side
How to Stop Parsefloat() from Stripping Zeroes to Right of Decimal