Domanda

I'm reading the John Resig blog about the Strict Mode in javascript, but i have a question.

One of the features of Strict Mode, is the use of JSON.parse and JSON.stringify, but i can use it WITHOUT "use strict".

If you write the same example that he's using on his blog:

var str = JSON.stringify({ name: "John" });
// Prints {"name":"John"}
alert( str );

You can see this working.

Why this is allowed? Am i missing something?

Thanks!

È stato utile?

Soluzione

There are a number of other new features and APIs that need attention, as well. The largest of which are Strict Mode and native JSON support.

You should read this as:

The largest of which are:

  • "Strict mode"
  • Native JSON support

Not as "JSON support, after enabling Strict mode".

See MDN: Strict mode for more information on this topic.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top