1.0 JS INTRODUCTION: Getting Started with Javascript

What is Javascript?

JavaScript is a scripting or programming language that allows you to implement complex features on web pages.

Javascript was previously used mainly for making webpages such as form validation, animation e.tc. Nowadays, javascript is also used in many areas such as server side development, mobile app development etc

How can you run javascript?

Because of its wide range of application, you can run javascript in several ways:

1. Using console tab of web browser.

2. Using Node.js.

3. By Creating web page.


1. Using Console tab of web browser

Here are the steps to run javascript in browser

i. Open your browser (Here I use google chrome)

ii. Open developer tool by clicking an empty area and select inspect.

(chrome shortcut f12)

iii. On the developer tools , go to the console tab. Then write javascript code and press enter to run the code

No alt text provided for this image

2. Using Node.js

Node.js is a backend runtime environment for executing js code. To run javascript using node.js; this are steps to follow

i. Install the latest version of node.js

ii. Install an IDE/Text Editor like visual studio code > In vs code , create a file > save it with .js extention (e.g index.js)

No alt text provided for this image

iii. Open up the terminal/command prompt > navigate to the file location > type node index.js > hit enter. (integrated terminal shortcut = CTRL + `)

iv. This is the output that you get from the terminal:

No alt text provided for this image

3. By Creating Web Pages

Javascript was initially created to make webpages interactive, that is why javascript and HTML go hand in hand . To run javascript from a page. These are the steps to follow:

i. Open VS Code > Go to File > New File > Save it with .html extension. For example, index.html.

ii. Create a doctype using shortcut (shift + ! ), If you can't copy mine or type html boiler plate on google and copy to your file or copy mine.

No alt text provided for this image

iii. Create a JS file, write the following JS code and save it with .js extension like main.js.

No alt text provided for this image

iv. From inside html file, link the javascript file(main.js) to the script file in the body.

No alt text provided for this image

v. Right click and open the browser from main.html with live server extension (Note: You can install live server from vs code extension by searching the keyword = "Live Server")

No alt text provided for this image

vi. To check if our JS code ran or not, Right click on the web page > Inspect > Choose console tab.

No alt text provided for this image

Next post will be deep dive into learning Javascript fundamental.

Thanks.

Salaudeen Olanrewaju

Front-End Engineer skilled in JavaScript, React.js, and TypeScript, focused on web accessibility and building easy-to-use, inclusive websites for better user experience.

2y

Nice series

Like
Reply

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics