Asking
Only logged in members can reply and interact with the post.
Join SimilarWorlds for FREE ยป

I have a question about Node.js ๐Ÿ˜ฌ๐Ÿ˜“

With JavaScript you can write: document.getElementByID
โ€” But with Node.js "document" doesn't exist.

So what's the Node.js version of "document.getElementByID"?
Northwest ยท M
Apples and Oranges. A typical web application, is two main parts: frontend and backend.

The frontend handles displaying the information in your browser.

The backend handles interfacing with databases, API services, networking services, security services, etc.

On the frontend, the basic level (plumbing) is the DOM, and you can manipulate it directly via Javascript. So, you have things like document.getElementByID.

Node.js, on the front end, manifests itself through Modules that allow you to write "Views". Typically, these "Modulees" prescribe specific templates, to write views. Within these views, the ID is used as a wrapper for code that describes what happens inside the DOM element identified by the ID, without the need to do document.getElementByID.

You will have to look up the reference material for the specific Module/technology to produce these views/flow. One of the most popular is React. But I suspect, given your question, that you may need to do some basic prep work, before going into the innards of Node.js.
Entheesa ยท 31-35, F
@Northwest Thank you so much for this explanation. And you're right, I'm too all-over the place. I've been learning JavaScript for starters, and wanted to write some code myself, which lead to downloading Node.js. Then my head exploded.
Northwest ยท M
@Entheesa [quote]Then my head exploded.[/quote]

๐Ÿคฃ

You should stick to learning Javascript for now. If you can even avoid everything related to the web, and focus on the Javascript language itself.

Once you've mastered that, you should take a DOM course.

Then take an HTML course.

Then take a CSS course.

Then you're ready to learn how to be a front-end programmer, with these building blocks mastered.

From that point on, you will be dealing with higher level environments. Manipulating the DOM, today, is akin to an electrical engineer, designing a circuit a single gate at a time, all 5 billion of them, for a single modern chip, when then can select a 5million gate filter, using a single element from a library.

And if you focus on the basic building blocks, you will make a far better programmer than a lot of the people whose resumes pass my desk every day.
Entheesa ยท 31-35, F
@Northwest Thank you, I really appreciate your advice. I've made a note of the order you suggest I learn these things. ๐Ÿ˜Ž
IHateViolence ยท 36-40, M
nodejs runs on the server
it doesn't have access to the DOM, which is only available on the front-end
basilfawlty89 ยท 31-35, M
NodeJS doesn't work with the DOM at all, so you wouldn't need to access DOM elements.

Node is more like a hybrid server and backend system, although you can install front-end frameworks like React or Angular.

That said, if you use React for the frontend part of the site, there's better methods than document.getElementByID.
basilfawlty89 ยท 31-35, M
@Entheesa you'll first need to learn a bit of React for this to make sense. Bear in mind React uses JSX, which is a bit of a hybrid between JavaScript and HTML. It seems weird at first, but it works well.

https://reactjs.org/docs/dom-elements.html
Entheesa ยท 31-35, F
@basilfawlty89 This already helps my understanding a lot, thank you! I'll find some videos to teach me about React. Would it be okay to PM you if I have other questions?
basilfawlty89 ยท 31-35, M
@Entheesa of course :)

 
Post Comment