DEV Community

Ranjith Jr
Ranjith Jr

Posted on • Updated on

Js | Strict Mode |

Strict Mode :
Enter fullscreen mode Exit fullscreen mode

Strict mode in JavaScript is a way to opt into a restricted variant of the language.
It helps you write cleaner code by catching common coding errors and "unsafe" actions,
such as assigning to global variables unintentionally. When strict mode is enabled,
some silent errors are converted to throw errors, which makes debugging easier.


'use strict'; // use or try js file 1st commend 

Enter fullscreen mode Exit fullscreen mode

let user = "Dhoni" ;
//user= " ms Dhoni"  correct method 

Enter fullscreen mode Exit fullscreen mode

//variable Spelling mistake ithukku dhan strict mood use panrom. 

use ="ms Dhoni"  //Error assignment undeclard variable use
console.log (user) ;

Output:
Dhoni 

Enter fullscreen mode Exit fullscreen mode

      //Keyword 
const interface = 'car' //Error Reserve keyword 

Enter fullscreen mode Exit fullscreen mode

const private = 'jack' //Error strict mood use pannalana error show agathu nama dhan identity pannannum.

Enter fullscreen mode Exit fullscreen mode

Top comments (0)