Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
August 12, 2020 10:14 pm GMT

Javascript for Absolute Beginners 01

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. 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.

let apple = "This is a lowercase apple";let Apple = "This is an uppercase apple";console.log(apple)> This is a lowercase appleconsole.log(Apple)> This is an uppercase apple

Identifiers

The identifier is the name given to a variable, function, parameter, or class by the programmer who wrote that program.

let varName = "This is an identifier";// In the above example, varName is the Identifier

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*/

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 errors after minifying javascript code.

Expressions

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

  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.


Original Link: https://dev.to/sinhasagar01/javascript-for-absolute-beginners-01-g52

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To