Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple JavaScript runs on ClientSide or ServerSide?

Normally JavaScript runs on the client side (browsers) only.

A Developer can also write event driven code on JavaScript which can be execute some function on event and can be run on some engine.

So that I am a bit confused and I have this questions:

1) Where does simple JavaScript runs, ClientSide or ServerSide?

2) What does the "Normally JavaScript runs on the client side" means?

3) Where can I read some references to this?

like image 336
Francisco Maria Calisto Avatar asked Dec 07 '22 21:12

Francisco Maria Calisto


1 Answers

Why the downvotes?

Are you all special snowflakes who can't help a fellow programmer without downvoting? Harsh, harsh people. May the hate you carry within your hearts consume your souls.

Basically, JS nowadays can be run on both client-side and server-side as well.

Being straightforward to answer the question, two simple examples:

On client-side, you can use JS to implement some logic based on user interactions, for eg, when a user ticks a checkbox, hovers a div to change its color, whatever, JS code can be executed as a response to these events and this is typically client-side code, because it all happens on client-side based mostly in response to user interactions.

Recently, nodeJS, all to be coded in JS, is a server-side technology which allows you to consume APIs, access DBs, etc, which are server-side actions, all using JS.

So, long story short: it can be executed in both client and server-side.

like image 94
Bruno Oliveira Avatar answered Dec 10 '22 11:12

Bruno Oliveira