Simple JavaScript runs on ClientSide or ServerSide?
Asked Answered
T

3

8

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?

Therapsid answered 27/7, 2016 at 22:42 Comment(3)
JS is simply a language. You can run it wherever you have an appropriate interpreter.Majewski
Javascript has traditionally been used in the browser (on the client side) to animate web pages and add logic to what would otherwise be static webpages created with HTML/CSS. Web browsers have their own "javascript engines". As 'the web' become more popular, so did javascript. With the prevalence of Javascript, some people decided they wanted to use Javascript on the back-end as well, which is what node.js accomplishes. It serves as another javascript engine, but it doesn't live inside the browser, so you can basically use it anywhere. However, javascript in the browser is still more common.Carnet
Why did I received a down vote?Therapsid
M
4

Does JavaScript run on client-side or server-side?

JavaScript can run anywhere

What means "Normally JavaScript runs on the client side"?

This statement is not true anymore, probably people meant by it that it was originally developed for use in browsers and therefore client-side. But I don't think you can generalize like that anymore.
See a short history of JavaScript.

Where can I read some references to this?

Merkley answered 27/7, 2016 at 22:52 Comment(0)
K
13

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.

Kalmick answered 27/7, 2016 at 23:16 Comment(0)
M
4

Does JavaScript run on client-side or server-side?

JavaScript can run anywhere

What means "Normally JavaScript runs on the client side"?

This statement is not true anymore, probably people meant by it that it was originally developed for use in browsers and therefore client-side. But I don't think you can generalize like that anymore.
See a short history of JavaScript.

Where can I read some references to this?

Merkley answered 27/7, 2016 at 22:52 Comment(0)
C
2
  1. in web it runs on client side and also in server side using Node.js
  2. That means Javascript is mostly used in browser
  3. You can read "JavaScript: The Definitive Guide" By David Flanagan
Copenhaver answered 27/7, 2016 at 22:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.