Author: Arpit Mandliya
- 23 May
TypeError: foreach is not a function in JavaScript
TypeError: .foreach is not a function occurs when we call foreach() function on object which is not array, Set or Map. To resolve this issue, you can use Object.keys() rather than directly calling foreach() on object or use Array.from() to convert array like object to array. In other words, call foreach() method only on iterable […]
- 23 May
TypeError: toUpperCase is not a function in JavaScript
TypeError: .toUpperCase is not a function occurs when we call toUpperCase() function on object which is not an string. toUpperCase() function can be only called on string. To resolve this issue, convert value to string using toString() ,method before calling toUpperCase() method. Let’s see with help of simple example [crayon-678cc2f6bb5f9218499815/] You will get following error […]
- 23 May
TypeError: split is not a function in JavaScript
TypeError: .split is not a function occurs when we call split() function on object which is not an string. split() function can be only called on string. To resolve this issue, convert value to string using toString() ,method before calling split(). Let’s see with help of simple example. [crayon-678cc2f6bb6ed365232424/] Output [crayon-678cc2f6bb6f0592980959/] We got this error […]
- 22 May
TypeError: replace is not a function in JavaScript
TypeError: .replace is not a function occurs when we call replace() function on object which is not an string. replace() function can be only called on string. To resolve this issue, convert value to string using toString() ,method before calling replace() method. Let’s see with help of simple example where we want to remove . […]
- 22 May
How to Unpack Array in JavaScript
In this post, we will see how to unpack array in JavaScript. Ways to Unpack array in JavaScript There are multiple ways to do it. Let’s go through them. Using Destructuring Syntax To Unpack array in Javascript into separate variable: Use destructuring assignment to unpack array in separate variable. Let’s see with the help of […]
- 21 May
Convert epoch time to Date in Javascript
In this post, we will see how to convert Convert epoch time to Date Javascript. There are multiple ways to do it. Let’s go through them. Using Date’s setUTCSeconds() To convert epoch time to Date in Javascript: Create Date object by passing 0 in its constructor. When you pass 0 to Date’s constructor, it will […]
- 21 May
How to Clear Array in TypeScript
In this post, we will see how to clear array in Typescript. There are multiple ways to do it. Let’s go through them. 1. By setting array’s length to 0 To clear array in TypeScript: Set length of array to 0. When length property is changed, all the elements that have index larger than its […]
- 21 May
[Fixed] TypeError: Assignment to constant variable in JavaScript
Problem : TypeError: Assignment to constant variable TypeError: Assignment to constant variable in JavaScript occurs when we try to reassign value to const variable. If we have declared variable with const, it can’t be reassigned. Let’s see with the help of simple example. [crayon-678cc2f6bbc43103530687/] Output [crayon-678cc2f6bbc47447418482/] Solution : TypeError: Assignment to constant variable Rename the […]
- 20 May
[Fixed] Syntaxerror: invalid shorthand property initializer in Javascript
Syntaxerror: invalid shorthand property initializer error comes when we use equals operator rather than colon to separate key-values(properties) in object. To resolve this issue, we need to use colon(:) rather than equals operator(=) between key and values of an object Let’s see with the help of example: [crayon-678cc2f6bbd5e305908461/] Notice that we have used = between […]