Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript throw vs console.error

throw Error("msg"):

1. Stops js execution.
2. Mostly used for code handling purpose.
3. Can alter main flow of execution.
4. This syntax is mostly same for all browser as this is specified and validated by W3C.
-----------------
console.error("msg"):

1. It just shows output in Red color at Browser console
2. It is mostly used to print values for debugging purpose.
3. Cannot harm main flow of execution.
 
PREVIOUS NEXT
Tagged: #javascript #throw
ADD COMMENT
Topic
Name
6+2 =