Javascript
JavaScript Fundamentals -- What is JavaScript?
  •  

What is JavaScript?

JavaScript:

  • Is a programming language made for the web and server-side applications
  • Makes web pages interactive and dynamic
  • Can calculate, manipulate, and validate data
  • Can be used to build entire web applications, such as with Angular, React, Vue, or Ember

JavaScript was initially introduced for running in the browser, but is now frequently run on servers as server side applications as well. Many features of the language can be used both in the web and on the server. When applicable throughout the course, features that are specific to one platform or another will be identified.

JavaScript in the browser is a little different from JavaScript on the server in regards to versioning and features. In the browser, new JavaScript features are released with browser updates. Thus, modern browsers generally get new features along with those updates and at different times from other browsers. If you're using a modern browser, you usually have access to many of the latest features. Be aware, though, that your users may not use modern browsers. JavaScript on the server, such as with Node.js, is different because new features are shipped with new versions of Node.js. Until you have updated the version of Node.js on your server or computer, you won't have access to the new features. This is good for making sure that your application doesn't break unexpectedly as you can build for a specific version of Node.

JavaScript has many syntax rules, and we'll cover many of them as we go along, but now is a good time to point out a few important ones.

  • JavaScript is case sensitive with its variable and function names and keywords
  • Variable and function names can contain numbers, letters, and underscores, but need to start with a letter or underscore
  • Variable and function names can not be reserved words, such as if, new, or return
  • White space is ignored, so you can use whatever type of white space you prefer

There are three main ways to run JavaScript code. They are:

  • Putting the code inside a script tag on an HTML page
  • Putting the code inside a .js file and loading that to an HTML page through the src attribute of a script tag
  • Using node to run the code on a computer or server

The first two ways are for running JavaScript in the browser; the third way is for running it only on a computer or server.