JavaScript Overview
We get started with programming JS and some fundamentals of that.
JavaScript was first created by Brendan Eich in the mid-90s while he worked for a browser company called Netscape. There are a few different origin stories, but supposedly it was called LiveScript originally. However, because of a marketing decision, in an attempt to ride the coattails of Java it was renamed to JavaScript.
There is no direct association between Java and JavaScript - they are wholly separate. Both are similar in that the are both programming languages, and some of the syntax (the structure or 'grammar' of the way that code is written)is similar as they both use the C-language as a basis, but otherwise, Java is to JavaScript as...ham is to hamster.
JavaScript(JS) is the most applicable, powerful and flexible language in the world today - it's a simple fact that no other language in the world allows us to work natively in the browser (client side) while also on the server (NodeJS) while also creating super-fast web-based applications (Single Page Applications (SPAs) Angular or React or Vue) while also using the same code to create native desktop applications (Electron) while also creating native mobile apps (React Native or NativeScript)...😅
Here's some sample code for your consideration...
/**
* `=` is an ASSIGNMENT OPERATOR. It takes whatever is on the right side and assigns it to the left.
* So...on the right, we have a STRING. We can tell it's a STRING b/c it's wrapped in "".
*
* On the left, a couple of things are happening:
* 1. `const` is a keyword that reserves space in memory.
* 2. After `const`, we give a name for that space in memory.
*
* The right side is assigned to the left side via an ASSIGNMENT OPERATOR, `=`.
*
* Oh yeah, notice that all of this stuff I am typing here is not code.
* These are comments - more specifically, multi-line comments.
*/
const js = "JavaScript";
const java = "Java";
/**
* 👇🏾 we have an EXPRESSION.
* An EXPRESSION is anything that evaluates to some value.
* In this case, this EXPRESSION evaluates to `false` (a BOOLEAN type).
* This expression uses a COMPARISON OPERATOR.
*
* Note that the code below is sort of pointless.
* It's true that we are evaluating an EXPRESSION, but those results are immediately discared.
* We are not using the results for any purpose, aside from illustrating these concepts.
* It would be more realistic to wrap this inside of a STATEMENT such as an `if` STATEMENT.
* STATEMENTS usually use the results of EXPRESSION to build some type of logic into our programs -
* 'if this, then that', etc.
*/
js !== java;
JS is a dynamically typed language. This means that we can change the type of a value stored in memory 'on the fly' (dynamically).
/**
* Like `const` 👆🏾 `let` also reserves space in memory.
* With `let`, we are allowed to replace the value in memory - with `const`, that is not the case.
*
* First, we place a value of type STRING (essentially groups of characters - words, whatever).
* Then, we replace the value stored in the memory under the name 'x' with the NUMBER 23.
* The fact that we can change the data type 'on the fly' or DYNAMICALLY,
* indicates that JS is a DYNAMICALLY TYPED LANGUAGE.
* Also note that we don't have to explicitly declare the type of our data.
*/
let x = "I'm a string!"
x = 23;
Terminology
It's important to be precise and particular with our terminology. This helps us learn more efficiently in the long run because with a better understanding of the 'language of the language,' we can understand 'official' well-written documentation better. So, here's a few terms to get us started, some of which we haven't experienced just yet.
Development/Programming
This one is open to interpretation, but, for our purposes, programming is to use characters, words and phrases familiar to humans to articulate a series of simple actions in order to create a complex,functioning program. This is accomplished by using a 'higher-level' language such as JS, which, by way of other 'lower level languages' (C++/Assembly, etc.) is compiled down to machine code (0s and 1s).
Code
Our typed text that we enter into our text editor of choice, VS Code.
Syntax
This is the 'grammar' of a programming language. If your linter says something about syntax error, then you are probably missing some {
or (
or ;
or something like that. Unlike spoken language, grammar counts for a lot more in programming
Compiler
Programs written by others (e.g. computer scientists) that take our code and compile it down to something for computers to understand (i.e. binary - 0s and 1s). It's worth noting that JS is an interpreted language - the 'compilation' happens as it's executing. This is as opposed to other languages that first have to compile down to an 'executable file.'
JS Engine
Usually referred to in the context of browser. Processing JS is only 1 of many different ‘engines’ in the browser.
Parser
For programming, refers to processing our sequence of characters, or reading our syntax and interpreting it for the compiler.
Linter
This is a package that we install that is like 'Grammarly' or any other 'spelling and grammar' checker. We can configure said linter with different style guides. This tooling in conjunction with an extension for our text editor, VS Code, will alert us with warnings or errors - not just for syntax 👆🏾 but for bad 'style,' etc.
Last updated
Was this helpful?