Introduction to Javascript
Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. Javascript was designed to specify the behaviour of the web pages.
Key Features
- Open-source
- Just-in-time compiled language
- Embedded along with HTML and makes web pages alive
- Originally names as LiveScript.
- Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc.
- Many giant companies like Microsoft, Paypal, Netflix, Uber, Google, Facebook, LinkedIn etc use Javascript.
This tutorial is for beginners to understand the modern javascript concepts.
Why you should learn Javascript?
- Javascript is one of the very popular language and you can develop both front-end and back-end applications using different frameworks of Javascript like node.js, react, angular etc.
- You can create scalable applications without any environment setup as it is available on all modern browsers.
- You can create mobile-applications too
- Developer friendly as you can find tons of existing frameworks and libraries which can be directly used in your application.
- Easy to learn language.
Why Javascript is popular?
One can't deny that Javascript is everywhere. Below key qualities of modern Javascript made it so popular.
- It integrates fully with HTML/CSS.
- Supported by almost all browsers.
- Easy and simple and scalable.
- Tons of frameworks and great community support and especially it's an open-source language.
Javascript Basics
Sample HelloWorld program
console.log("Hello, World!"); // prints Hello, World!
console.log is used to print the message to get displayed to the user.
Statements and Semicolons
- The above line of code is called a statement.
- Statements are seperated by semi-colon(;)
- Javascript doesn't throw error in absence of semi-colons if a line break is present between them. Javscript interprets line break as implicit semicolon.
- It's always a best practice to add semi-colon at the end of the statement.
Comments
- Single line comments
//
is used to comment a single line
- Multi line comments
/**/
is used to comment multiple lines.
Modern Mode
- You must explictly declare with directive
"use Strict"
or'use Strict'
at the top of the script to tell the javascript should work in strict mode.