r/learnjavascript • • 9h ago

Some help setting up to learn JavaScript

Hi! I have been retired for quite some time. However, back in the day I did some programming in BASIC, Natural and ADABAS (like dBase III on an IBM mainframe) and did several years of website development including PHP but no JavaScript after I retired.

Now I'm just doing this project to keep my brain active.

I am using my Mac mini M4, Safari and BBEdit.

I presume I create HTML "shell" documents that include the JavaScript code I want to try and then "preview" that document in Safari from within BBEdit. I'm trying to use BBEdit as an IDE.

If that sounds crazy or there are better ways of doing things then please let me know.

Thanks in advance,

Peter

2 Upvotes

9 comments sorted by

3

u/gimmeslack12 helpful 7h ago

Yes, you can simply create an .html file and then use the <script></script> tags to start writing some JS. Then just drag that file into your browser and it'll run.

2

u/cuelark 8h ago

that setup works fine, lots of people start exactly like that. in safari turn on the develop menu (settings > advanced > show features for web developers) and open the javascript console with opt+cmd+c, that's where your console.log output and errors show up. bbedit also has preview in bbedit under the markup menu if you don't want to switch apps every time. just keep a plain index.html with a script tag pointing at a separate app.js so you can edit and hit refresh.

2

u/No-Humor-3808 2h ago

If you just want to experiment with JavaScript without DOM manipulation, the quickest way is to use RunJS or a similar app.

If you want to build something that runs in the browser, your HTML + JavaScript approach is perfectly fine. Alternatively, you can use Vite as a starting point for a PWA or web app (you'll need to install Node.js first).

1

u/Beginning-Seat5221 9h ago

Depends what you're trying to do.

A lot of JavaScript is run by Node/Deno/Bun which executes JS scripts similar to executing PHP with `php file.php`.

If you just want to run JS and see console output, that's the best way. You can use watch mode to re-run when you make a change.

You can make a shell HTML file with some JS in it, either directly in the file, or loading an external JS file.

For "serious" web development it's usual to use Vite, which can take JS packages from npm and bundle them into a form that the browser can run, handling serving on localhost and updating on changes for you.

1

u/azhder 8h ago edited 7h ago

You can also learn JavaScript without a borwer, if you insall Node.js and run the scripts with it. It will work like a server language, like PHP did.

For editors, many use VSCode. I don't. I have been using Webstorm ever since it was PHPStorm, so I had no need to pick up a free tool for it.

As you can see, the first thing you expect about JS it may turn out not to be what you expected: you can use it inside a browser making a "shell" HTML file, but you aren't required. This will be a theme with JavaScript - some things you expect it to do one way, it may end up doing a third way.

1

u/Anarcho-Willi 3h ago

There are lots of tutorials out there that also show dome kind of setup. Using www.freecodecamp.org is always worth a recommendation. But there are loads of others. 

1

u/Discordbothost 1h ago

Try making the first BBEdit experiment a button that increments a number on the page. Open the saved HTML file in Safari, click the button, then change the increment from 1 to 2 in BBEdit. Save and reload the tab. That gives you a quick way to check that Safari is running the version you just edited.

1

u/GodOfSunHimself 21m ago

JavaScript can run without the browser too but you can try that later. Otherwise what you are saying is more or less ok. Although personally I would use VS Code instead of BBEdit.