Skip to main content

Command Palette

Search for a command to run...

Type Error / Reference Error

Published
β€’2 min readβ€’View as Markdown
Type Error / Reference Error

πŸ’‘ Getting Struck while coding, So, I am here to explain to you*.*

https://media.tenor.com/FFkOPFbwhu0AAAAd/computer-funny.gif

  • The error makes you fed up with coding. Wanna quit coding?

    • HELLO!!! DON'T DO IT. YOU ARE MISSING FUNπŸ˜πŸ˜πŸ˜β€¦..

TYPE ERROR

const num = 123
num.toUpperCase() // throws Type error
  • Type error shows that code cant is performed.

  • It shows the unsuccessful code.

  • Mainly Type Error will be observed in Modifying the value which cant be performed.

  • The name refers to Type in this case, When we access or try to change the type of const β€”- It gives an error

For example,

Num = 123 Given, it is stored in the form of a number.

So Upper case cant be performed,

If else,

const num = "abc"
num.toUpperCase() // o/p is ABC. Because it is stored in string

REFERENCE ERROR

function text() {
var str = "Hello World";
return str;
}
console.log(str) // Gives refernce error
function text(){
}
return

In the 1st section of code, The console.log() is outside of the Function Block.

So, It gave a reference error

  • A reference error is observed when the code cant is reached.

  • When the code is out of scope.

  • When the code cant is initialized.

  • As the name says, Reference means the path of the code, When we try the wrong path or miss the path β€”- Error arrives

Now, Start coding…………………….πŸ˜πŸ˜πŸ˜πŸ˜πŸ˜πŸ˜πŸ™ŒπŸ™ŒπŸ™ŒπŸ™Œ