+ 1
How do you use JS in a website or app?
Okay so Ive done dozens of js tutorials and read many books on the basics. How do you start using it in the real world? Like if I have a project full of Html and css and I have a blank js file, how do I know what to start writing for the functionality I need?
5 Answers
+ 2
To add functionality or create my website. I mean, one of the most basic examples of what you can do with JS is to add classes and create new elements with which you can interact. Even the functionality of some components (such as a navbar in a mobile device), depend strongly on JS for proper operation.
In the "real world", currently you also depend a lot on JS to get data from a server and display it on your page. In the same way you can build the entire layout of your site using JS frameworks and template engines. You can do validations on the client side, and much more (the options are expanded with things like the HTML Canvas element, which allows you to even create games by adding JS)
The options are very varied and depends a lot on you. If you have a blank file, think about what you need extra functionality or what new element you can use on your website to make it more interactive and attractive (a slider, a responsive navbar, add classes to an element to change how it is displayed, hide / show elements, etc)
+ 2
To know how to use js with html and css start with some simple projects like login page or some data entry page
for example in a sign up page we can use js to have proper validations for all the fields
like checking password strength, validating email validating empty fields etc..
+ 1
In that case I start by thinking how I can do the task I want to do (add an effect, change something, make an element more interactive). If I see that it is something fairly complex I also evaluate if I need a library (and if it has dependencies, I like to have minimal dependencies)
Later I start to develop my idea. If problems arise I see other people's code and I start to study it. If I do not have something clear then I search, and only when I understand things do I encourage myself to rewrite everything.
0
Thanks for your answers everyone, however I dont think you guys are understanding my question. I know what can be done, but how do you know WHAT TO WRITE? Like how do you actualky start writing the JS? Like do you start with functions or variables or how the heck do you know what to write?
For example, I have a small app with a map, a search box, and a JSON file full of data. How do you know what JS to write to actually create the functionality you need?
0
@Mickel SĂĄnchez I appreciate you trying to help me out but your still not understanding my question.
How do you know what to start WRITING? After you've written down your steps for functionality and everything, how do you know how to actually write it with the syntax itself? Like do you start with variables or functions or what?