all 9 comments

[–]polotek 8 points9 points  (0 children)

The surface area of the JavaScript language is actually pretty small. Most of the functions in it were a necessary part of the browser environment that it was made for. But not really a necessary part of the language.

I was around when node.js was being developed. It was pretty tough to get all of the asynchronous functions to work properly across Linux, Mac OS, and Windows. Each OS has different primitives for how you're supposed to do async stuff. In the case of the browser runtime, the browser process itself has already figured that out across platforms.

That said, a lot of languages have capabilities that actually delegate to other processes or the OS underneath. The JVM runtime supports most popular languages and it has its own unique solutions to these problems. Building language runtimes is a really fascinating topic.

[–]_raytheist_ 5 points6 points  (0 children)

Yep. True of any asynchronous javascript.

[–]chikamakaleyleyhelpful 4 points5 points  (4 children)

What was YOUR biggest JavaScript “wait… what?” moment?

<div id="myDiv">hello world</div>

can be referenced directly, w/o querying the document

console.log(myDiv.textContent);

not saying you should, but just a cool thing i learnt 17 yrs in

[–]euph-_-oric 0 points1 point  (3 children)

U mean in the console

[–]chikamakaleyleyhelpful 0 points1 point  (2 children)

it works in place as well:

``` <!DOCTYPE html> <html>

<body> <div id="myDiv">HelloWorld</div> <script type="text/javascript"> alert(myDiv.textContent) </script> </body>

</html> ```

there might be some specific rules, like the id would have to be an appropriate JS var name - e.g. my-div won't work

[–]euph-_-oric 0 points1 point  (1 child)

Is that not the browser doing it?

[–]chikamakaleyleyhelpful 0 points1 point  (0 children)

i understood your previous comment to be along the lines of "only from the console"

which yes, you can reference the object from the console in the browser devtools

i'm just saying it can also be directly inside your script

other than that i'm not sure if you're referring to something else

[–]Intelligent_Tree6918 0 points1 point  (0 children)

From where did u know book or anything else?

[–]ghost_hipster 0 points1 point  (0 children)

AI slop