r/learnjavascript • • 3d 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

7 Upvotes

13 comments sorted by

3

u/cuelark 3d 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.

3

u/gimmeslack12 helpful 3d 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.

3

u/No-Humor-3808 3d 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).

2

u/Anarcho-Willi 3d 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. 

2

u/GodOfSunHimself 3d 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.

1

u/Beginning-Seat5221 3d 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 3d ago edited 3d 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/Discordbothost 3d 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/justanaccountimade1 2d ago

See structure here:

https://www.reddit.com/r/learnjavascript/s/vfr8TnMzBA

You put that in a textfile that you call something.html and open it in the browser. The browser then shows the result of the console.log in the console (F12 in Chrome, you'll have to look up how to open it in Safari).

1

u/delventhalz 2d ago

The most basic thing you can do is open the Developer Tools on your browser. There is a console in there, where you can just run JavaScript. Chrome even has a Snippets section where you can write longer scripts and then run them in the browser console.

Moving beyond that, yeah, make an HTML file and add a script tag. Then open that HTML file in your browser. Alternatively, you can install Node and run scripts from your command line.

I've never used BBEdit, but I imagine it will work fine. A lot of JavaScript devs use VS Code, which is particularly good for TypeScript. It's a bit of a bloated MS monster at this point, but there is also a reason most web devs use it.

As you move forward, reference MDN often for reference (can usually just search for "MDN <syntax I need to know about>"), and javascript.info is great for tutorials.

1

u/HelloCraftymon 2d ago

As a beginner you don't even have to use an editor. You can directly go to w3schools ( https://www.w3schools.com/js/default.asp ) with the built in editor on their website. And practice it before you try it on your own. The website is one stop for all type of web development.