DEV Community

Cover image for Javascript for Absolute Beginners #01
Sagar Kumar Shrivastava
Sagar Kumar Shrivastava

Posted on

Javascript for Absolute Beginners #01

Note: I will put reference links or explain the Jargons used in this article at the bottom of the article.


This is my first article for absolute beginners who wanted to learn Javascript from scratch, in these articles I will try to cover every tiny bit of javascript.


What is Javascript?

Javascript is a dynamic programming language.1 Javascript enables interactivity in Web pages.


Javascript Syntax

  • Case Sensitive
  • Identifiers
  • Comments
  • Statements
  • Expressions

Case Sensitive

Javascript is a case-sensitive language. It means apple & Apple is not the same variable.2

let apple = "This is a lowercase apple";
let Apple = "This is an uppercase apple";

console.log(apple)
> This is a lowercase apple
console.log(Apple)
> This is an uppercase apple
Enter fullscreen mode Exit fullscreen mode

Identifiers

The identifier is the name given to a variable, function3, parameter4 by the programmer who wrote that program.

let varName = "This is an identifier";

// In the above example, varName is the Identifier
Enter fullscreen mode Exit fullscreen mode

Rules for writing an identifier name.

  • The first character of the identifier name must start with a letter (a-z, A-Z) / (_ underscore) / ($ dollar sign)
  • The other character of the identifier name can be a letter (a-z, A-Z) / (0-9) / (_ underscore) / ($ dollar sign).
  • JavaScript defines a list of keywords that have special uses. You cannot use the keywords as the identifiers. See Full List of keywords

Comments

Comments are common practice in all programming languages for leaving notes or explaining your code to yourself and others.

There are two kinds of comments in javascript.

  • Single-line comment
  • Multi-line comment or Block comment

Example:

// this is a single-line comment


/*
* This is a block comment that can
* span multiple lines
*/
Enter fullscreen mode Exit fullscreen mode

Statements

Statements are a sequence of commands that needs to be executed. Statements should end with a semicolon(;), strongly recommended but not required.

Semicolon(;) is required for the readability of the code and also to avoid syntax errors5 after minifying6 javascript code.


Expressions

An expression is a block of code that evaluated to a value.

Below are the types of Expressions in Javascript. I will explain these in the next article.

  1. Arithmetic expressions - Ex. 2 + 3
  2. String expressions - Ex. 'sagar' + 'sinha'
  3. Primary expressions - Ex. true, false
  4. Array and object initializers expressions - Ex.[], {}
  5. Logical expressions - Ex. &&, ||
  6. Left-hand-side expressions - Ex. new, super
  7. Property access expressions - Ex. object.property
  8. Object creation expressions - Ex. new object()
  9. Function definition expressions - Ex. function() {}
  10. Invocation expressions - Ex. f(0)

Cheers! See you again in the next article. (Next article will be about expressions in detail.)

Jargons Explained

  1. Dynamic programming language - In computer science, a dynamic programming language is a class of high-level programming languages, which at runtime execute many common programming behaviors that static programming languages perform during compilation. Source - Wikipedia

Related Links for more informatiion - mdn , wikipedia , sitepoint

  1. Variable - Variables are named reference to a value. Further details on the variables in the coming articles.

  2. Function - A function is a block of statements that are used to perform a specific task. Further details on the variables in the coming articles.

  3. Parameter - Will learn in detail in an upcoming article.

  4. Syntax errors - An incorrect use of pre-defined syntax cause a syntax error. For example, if you leave off a closing brace (}) when defining a JavaScript function, you trigger a syntax error.

  5. Minifying - Minifying the code means removing whitespaces, comments, and other unnecessary stuff that is not needed for the execution of the code. This process is used for reducing the file size.

If you guys have any doubt or anything you haven't understood, please feel free to ask in the comment.

Top comments (0)