Business

header ads

JavaScript: usage of use strict?

we use this string or statement? 
 
Structure of code
 'use strict'; 
We will declare the before any code So here, everything in the file.js will be executed in strict mode.
  1. // File Name: mysamplejsfile.js  
  2.   
  3. 'use strict';  
  4. var strcode = 0;  
  5. .....  
  6. .....  
  7. // other code  
  8. .....  
Insert this 'use strict'; text on the start of your function body, as shown below. It means that everything in the scope of this function will be executed in strict mode.
  1. function sample() {  
  2.     'use strict';  
  3.     ...  
  4.     // other code  
  5.     ...  
  6. }  
Note
For example, everything will be non-strict except for the function we mark 'use strict' inside the function. 

Post a Comment

0 Comments