javascript
- 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-6768a3506c4c9742772873/] 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-6768a3506c74c463361792/] Output [crayon-6768a3506c750436805667/] 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
[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-6768a3506cb77101151165/] Output [crayon-6768a3506cb7a173035695/] 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-6768a3506cc87386594246/] Notice that we have used = between […]
- 20 May
[Fixed] TypeError: map is not a function in Javascript
map is not a function in Javascript TypeError: .map is not a function occurs when we call map() function on object which is not an array. map() function can be only called on array. Let’s see with help of simple example: [crayon-6768a3506cd4d074286057/] You will get following error when you execute the program: [crayon-6768a3506cd50269082152/] We got […]
- 08 February
Round to 2 decimal places in JavaScript
In this post, we will see how to round to 2 decimal places in javascript. Using Math.Round() to Round to 2 Decimal Places in JavaScript You can use Math.round() function to round number to 2 decimal places in javascript. You need to multiply number by 100, apply Math.round() and then divide by 100. [crayon-6768a3506ce42793648727/] Output: […]