How to use strict mode.

Strict Mode is a new feature that allows you to place a program, or a function, in a “strict” operating context. This strict context prevents certain actions from being taken and throws more exceptions.

how to use:

Being a scripting language, sometimes the JavaScript code displays the correct result even it has some errors. To overcome this problem we can use the JavaScript strict mode.

The JavaScript provides “use strict”; expression to enable the strict mode. If there is any silent error or mistake in the code, it throws an error.

syntax:

<script>  
console.log(sum(10,20));  
function sum(a,a)  
{  
"use strict";  
return a+a;  
}  
</script>  

Leave a comment

Your email address will not be published. Required fields are marked *