What does JavaScript's strict mode exactly do regarding implicit global declarations?

what is javascript
what does javascript do
what is javascript used for
javascript tutorial
what does javascript look like
what is javascript used for in web design
learn javascript
javascript examples

From MDN article about strict mode:

First, strict mode makes it impossible to accidentally create global variables. In normal JavaScript mistyping a variable in an assignment creates a new property on the global object and continues to "work" (although future failure is possible: likely, in modern JavaScript). Assignments, which would accidentally create global variables, instead throw an error in strict mode:

'use strict';
                       // Assuming a global variable mistypedVariable exists
mistypeVariable = 17;  // this line throws a ReferenceError due to the 
                       // misspelling of variable

What does this mean? Does the engine detect if a variable with a similar name already exists(?!) or does strict mode merely prohibit declaring global variables outside of global scope?

The above quotation seems to hint the first possibility but this seems... weird?

The comment in the quoted code is misleading: The "Assuming" part is irrelevant. It should really read: "Assuming that no global variable with exactly this name was defined with let or var,..."

But do note what the purpose was of the code snippet and the comment: to show that in strict mode it is much easier to spot spelling mistakes. In sloppy mode the spelling mistake would go unnoticed (no errors) and you would be working with two variables without knowing it (at least for a while)

What is JavaScript?, To put things simply, JavaScript is an object orient programming language designed to make web development easier and more attractive. In  JavaScript is a scripting or programming language that allows you to implement complex features on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. — you can bet

As requested, I'll make this into an answer :)

I think you understand what happens here already, and are just getting confused through reading that quote about "assuming a global variable..." too literally. (I will admit it is phrased in such a way as to possibly lead to this confusion though.) The real situation is very simple, and has nothing to do with variables having "similar names" (which JS has no concept of):

What is being talked about is what happens if you assign a value to a variable which has not been formally declared (variables are declared with one of the keywords var, let or const). Not declaring your variables is bad practice, and in strict mode will throw an error - this is a good thing and warns you of your mistake. But in non-strict mode, JS will happily accept this and think you wanted to declare a global variable of that name. This is almost never what you actually want, as it pollutes the global namespace, doesn't inform you of your error, and may lead to all sorts of tricky bugs later.

What Does JavaScript Do?, JavaScript is a scripting language used to create and control dynamic website content, i.e. anything that  JavaScript (/ ˈ dʒ ɑː v ə ˌ s k r ɪ p t /), often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm.

does strict mode merely prohibit declaring global variables outside of global scope?

strict mode definitely doesn't prohibit declaring global variables from anywhere. In non-strict mode, if you write:

someVar = 't';

it will evaluate to:

window.someVar = 't';

( why is this happening? ) despite of writing inside or outside of a function scope. actually, the line was both declaring and evaluation of variable ( look again, it doesn't have var so it shouldn't declare anything! ).

But it would cause such a side-effect that wasn't totally fine and they've introduced strict-mode which when is active, our first line will throw an error. because it's just evaluation without declaring it first.

now if you need to manipulate global scope inside of a function scope, you only should global object as reference:

var someGlobalVar;
var someOtherGlobalVar;

function hello() {

    // this will make *someGlobalVar* to be redefined in the inner scope
    // someGlobalVar != window.someGlobalVar
    var someGlobalVar;

    // manipulating inner variable, not global one
    someGlobalVar = 's';


    // it's fine, you've accessed global object correctly
    window.someGlobalVar = 's';


    // you're still editing global object, because
    // there's no other variable inside of this scope having the same name
    someOtherGlobalVar = 's';

}

What Is JavaScript Used For: Find Out What Can You Do With , What can JavaScript Do? This section contains some examples of what JavaScript can do: JavaScript Can Change HTML Content; JavaScript Can Change HTML  JavaScript Assignment Operators Assignment operators are used to assign values to JavaScript variables. Given that x = 10 and y = 5 , the table below explains the assignment operators:

What Is JavaScript? A Guide for Total Beginners, For a tutorial about assignment operators, read our JavaScript Assignment Tutorial. JavaScript String Operators. The + operator, and the += operator can also be  Many Internet Web sites contain JavaScript, a scripting programming language that runs on the web browser to make specific features on the web page functional. If JavaScript has been disabled within your browser, the content or the functionality of the web page can be limited or unavailable.

What is JavaScript, In this article, we discuss what JavaScript can be used for on the web, its downsides, and how to use it responsibly.

JavaScript Operators Reference, What can in-browser JavaScript do? Modern JavaScript is a “safe” programming language. It 

Comments
  • I think your confusion comes from the idea that mistypeVariable = 17; is a proper declaration. It would be in sloppy mode, but in strict mode this is not a variable creation, so unless you already had a let or var for it, it is an error.
  • I'm not sure I understand the question. In strict mode, this will throw an error. In "sloppy mode", it will implicitly create a global called mistypeVariable, with value 17 - which is almost always much less helpful behaviour. (Even if that global never gets in your way, which it probably won't, you won't be aware of the mistake until later when you're trying to figure out some strange bug.)
  • @trincot (1) so how to declare globals in strict? or does strict prohibit globals at all? (2) As per my quotation: "Assuming a global variable mistypedVariable exists this line throws a ReferenceError" - emphasis mine. My understanding is that JS engine must therefore check for similar names??
  • I think your confusion stems from interpreting that comment in your quoted snippet too literally. The error is not thrown because of any perceived "similarity of name" to another variable, it's thrown pure and simply because you're using an undeclared variable. It doesn't matter what other variable names you're using.
  • The comment in the quoted code is misleading: The "Assuming" part is irrelevant. It should really read: "Assuming that no variable with exactly this name was defined with let or var,..." But note what the purpose was of the code snippet and the comment: to show that in strict mode it is much easier to spot spelling mistakes.
  • Upvote but can't split the green tick into two, sorry :)