๐ŸŒ
MDN
mdn2.netlify.app โ€บ en-us โ€บ docs โ€บ web โ€บ javascript โ€บ reference โ€บ operators โ€บ in
in operator - JavaScript | MDN
March 25, 2022 - The in operator returns true if the specified property is in the specified object or its prototype chain.
๐ŸŒ
TypeScript
typescriptlang.org โ€บ docs โ€บ handbook โ€บ typescript-from-scratch.html
TypeScript: Documentation - TypeScript for the New Programmer
JavaScript (also known as ECMAScript) started its life as a simple scripting language for browsers. At the time it was invented, it was expected to be used for short snippets of code embedded in a web page โ€” writing more than a few dozen lines of code would have been somewhat unusual.
Discussions

A better streams API is possible for JavaScript
They propose just using an async iterator of UInt8Array. I almost like this idea, but it's not quite all the way there ยท type Stream = { next(): Promise<{ done, value: UInt8Array }> } I propose this, which I call a stream iterator More on news.ycombinator.com
๐ŸŒ news.ycombinator.com
147
427
1 day ago
What does the 'in' keyword in javascript mean? - Stack Overflow
Your confusion seems to arise from the fact you declared the var aa = 1; in a block. You should know that the scope of a variable in JavaScript is either a function of the global scope and that declarations are hoisted. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Is it just me does anyone else feel that javascript world has gone crazy?

As someone who has written JS for well over a decade I can confirm this. JavaScript is going through something not unlike what Java went through in the 90s. It was getting popular, so everyone had their own ideas on the best way to write it. Frameworks started popping out of the woodwork left and right, and some gained traction, and everyone had their own opinion on each. Eventually POJO (plain old Java object) became more popular -- meaning quit using objects these frameworks provide and use the ones Java provides. One can only hope we see the same with JS.

As to how people keep up with it, I suspect that's not quite how it works. People learn a specific technology and tend to stick with it, so as others pop up they begrudgingly go along with it, but don't really want to take the time to jump head-first into the topic, and tend to rely on the "evangelists" of said technology to keep them in line. This is why I've had a falling out with JS. It used to be a language I could do anything with, but now it's a language that is easy to learn, but impossible to master as long as new frameworks or methodologies keep coming out of nowhere and becoming popular.

The community does seem to have become rather content with React, but only time will tell.

More on reddit.com
๐ŸŒ r/learnprogramming
179
911
May 3, 2017
Does anyone still use IndexedDB in JavaScript? : webdev
๐ŸŒ r/webdev
๐ŸŒ
The Odin Project
theodinproject.com โ€บ paths โ€บ full-stack-javascript โ€บ courses โ€บ javascript
JavaScript | The Odin Project
Make your websites dynamic and interactive with JavaScript! You'll create features and stand-alone applications.
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
That's just how string iterators work in Javascript: one object for every byte. ... | Hacker News
13 hours ago - In the future it should be entirely possible for the engines to optimize even more aggressively too: they should be to skip making the object if the producer of values is a generator function and the consumer is a for loop ยท And yes, if that were the sole string interface, things would be ...
๐ŸŒ
Lobsters
lobste.rs โ€บ s โ€บ vlpddk โ€บ we_deserve_better_streams_api_for
We deserve a better streams API for JavaScript | Lobsters
2 days ago - But you've still got StreamIterator<T> for every other kind of data, so if you really do need a stream that can emit individual bytes, you can use StreamIterator<number>, or if you want to deal with decoded JavaScript strings or code points, you can use StreamIterator<string>, or if you're dealing with a bunch of files you might have StreamIterator<File> which could even be converted into a StreamIterator<StreamIterator<Uint8Array>> if that's what you needed.
Find elsewhere
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
A better streams API is possible for JavaScript | Hacker News
1 day ago - They propose just using an async iterator of UInt8Array. I almost like this idea, but it's not quite all the way there ยท type Stream<T> = { next(): Promise<{ done, value: UInt8Array<T> }> } I propose this, which I call a stream iterator
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Operators โ€บ in
in - JavaScript | MDN
July 8, 2025 - The in operator returns true if the specified property is in the specified object or its prototype chain.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ explain-the-purpose-of-the-in-operator-in-javascript
Explain the purpose of the โ€˜inโ€™ operator in JavaScript
After that, we used the constructor function to create the object of the table class. We used the ?in' operator to check whether the property exists in the object prototype. In JavaScript, every object contains the toString() method in its prototype, that's why it returns true.
๐ŸŒ
Can I Use
caniuse.com โ€บ mdn-javascript_operators_in
JavaScript operator: in | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-use-the-in-operator-in-javascript
How to use the "in" operator in JavaScript?
In this article, we are going to explore the 'in' operator and how to use it in JavaScript. The in operator is an inbuilt operator in JavaScript that is used for checking whether a particular property exists in an object or not.
๐ŸŒ
DEV Community
dev.to โ€บ seanwelshbrown โ€บ using-the-in-operator-in-javascript-46if
Using the "in" Operator in JavaScript - DEV Community
September 30, 2020 - I'm glad you asked. In JavaScript, the "in" operator is an inbuilt operator that is used to check whether a property exists in an Object.
๐ŸŒ
Mozilla
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Guide โ€บ Expressions_and_operators
Expressions and operators - JavaScript | MDN
The operands can be numerical, string, logical, or object values. Strings are compared based on standard lexicographical ordering, using Unicode values. In most cases, if the two operands are not of the same type, JavaScript attempts to convert them to an appropriate type for the comparison.
๐ŸŒ
DEV Community
dev.to โ€บ rfornal โ€บ javascript-in-operator-4la0
JavaScript In Operator - DEV Community
August 24, 2020 - The in operator is an built-in operator in JavaScript which is used to check whether a particular property exists in an object or not.
Top answer
1 of 3
17

This tests if the window object has a property (filled or not) whose key is "aa".

This operator is very useful because it works even if the value is undefined :

window.aa = undefined; // or just aa=undefined if you're in the global scope
console.log('aa' in window); // logs true

It also works if the property isn't enumerable :

console.log('length' in []); // logs true

In your case, there may not be an aa value, but if the alert shows you true, the property was added to window.

MDN reference on in

Note that the for...in statement is different in that it doesn't really use the in operator but is a specific construct.

MDN reference on for...in


EDIT : an explanation of your edited question (very different from the first one) :

Your confusion seems to arise from the fact you declared the var aa = 1; in a block. You should know that the scope of a variable in JavaScript is either a function of the global scope and that declarations are hoisted. So your code is in fact equivalent to

var aa = undefined;
if (!("aa" in window)) { // aa is in window, so we don't enter here
    alert('oh my god');
    aa = 1;  
}  
alert("aa" in window); // yes, the property exists, it's true
alert(aa); // aa is still undefined
2 of 3
2

Taking the alerts in order:

  • alert #1 is never reached because ("aa" in window) === true so the if boolean condition is false.

JavaScript has function scope and the variable aa is "hoisted" up to the top of the scope first, so it is defined.

  • alert #2

"aa" in window is true because the variable was added to the window object when it was hoisted up. Equivalent to just writing:

var foo;
"foo" in window (which === true)
  • alert #3

From the Standard ECMA-262 ECMAScript Language Specification :

A variable statement declares variables that are created as defined in 10.5. Variables are initialised to undefined when created. A variable with an Initialiser is assigned the value of its AssignmentExpression when the VariableStatement is executed, not when the variable is created.

So aa is undefined since the assignment was never executed.

๐ŸŒ
TypeScript
typescriptlang.org
TypeScript: JavaScript With Syntax For Types.
Catch errors early in your editor. TypeScript code converts to JavaScript, which runs anywhere JavaScript runs: In a browser, on Node.js, Deno, Bun and in your apps.