Skip to content

Instantly share code, notes, and snippets.

@srkmrs
Last active December 22, 2015 03:19
Show Gist options
  • Select an option

  • Save srkmrs/6409678 to your computer and use it in GitHub Desktop.

Select an option

Save srkmrs/6409678 to your computer and use it in GitHub Desktop.

Revisions

  1. srkmrs revised this gist Sep 3, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion use_strict
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    By marking the top of the script block or function with the "use strict” directive, the compiler will provide early warnings and errors for common coding mistakes, and restrict the usage of some dark corners of the JavaScript language.
    By marking the top of the script block or function with the "use strict” directive,
    the compiler will provide early warnings and errors for common coding mistakes,
    and restrict the usage of some dark corners of the JavaScript language.

    Let you see how the following sample code interact with Strict Mode.

  2. srkmrs revised this gist Sep 2, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion use_strict
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    By marking the top of the script block or function with the "use strict” directive, the compiler will provide early warnings and errors for common coding mistakes, and restrict the usage of some dark corners of the JavaScript language.

    Let you see how thefollowing sample code interact with Strict Mode.
    Let you see how the following sample code interact with Strict Mode.

    Code

  3. srkmrs created this gist Sep 2, 2013.
    31 changes: 31 additions & 0 deletions use_strict
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    By marking the top of the script block or function with the "use strict” directive, the compiler will provide early warnings and errors for common coding mistakes, and restrict the usage of some dark corners of the JavaScript language.

    Let you see how thefollowing sample code interact with Strict Mode.

    Code

    "use strict";
    a = 100;
    b = 200;
    document.write(a + b);


    Results
    Error was detected; no results were produced.

    Errors
    Uncaught ReferenceError: a is not defined

    Expected Code

    "use strict";
    var a = 100;
    var b = 200;
    document.write(a + b);

    Results
    300

    Errors
    No errors.
    (Note that Strict Mode is still under development in many browsers.)