Why does JavaScript "use strict" non-magic commentary?

Every other language I've used makes something akin to magic comments when you want to change compiler / interpreter level things:

eg. in C, you use a preprocessor:

#pragma GCC dependency "parse.y"

      

In Ruby's comment:

# encoding: utf-8

      

In Haskell, the comment:

{-# LANGUAGE ForeignFunctionInterface, CPP #-}

      

In * nix scripts, the comment:

#!/bin/sh

      

But in JavaScript the string . As well as the actual data of the program. It seems crazy to me, does the interpreter make it a string literal and then check its value? Or this particular string was never created (or no equivalent in JS) And why String? This is so atypical and illogical (since this is programmatic data, not metadata) that I was very confident that my friend was pulling my leg when he told me this.

"use strict";

      

+3


source to share





All Articles