In 10 days, by Brendan Eich ,initially created to “make web pages alive !"
Its Dynamic
supports two programming language paradigms: functional & object-oriented programming
It’s deployed as source code
Its Asynchronus
Language described by these standards is called ECMAScript, not JavaScript
First version of the standard.
Strict Mode
This strict context prevents certain actions from being taken and throws more exceptions
"use strict";
let,classes,=> ,... and Much More!
Change HTML element content, element.innerHTML.
Writing output , document.write().
Writing into the browser console, console.log().
JavaScript Declarations are Hoisted
a variable can be used before it has been declared.
x = 5; // Assign 5 to x elem = document.getElementById("demo"); // Find an element elem.innerHTML = x; // Display x in the element var x; // Declare x
Similarly Function declrations are Hoisted
JavaScript only hoists declarations, not initializations.
var x = 6;
const y= 6; ES6
let x = 6; ES6
Note - JavaScript is Case Sensitive
Number var length = 16;
String var lastName = "Johnson";
Object var x = {name:"J", id:25};
Undefined var undef = undefined;
Null var nul = null;
Array var arr = ["A",'J',123,null];
used to store various keyed collections and more complex entities.
All JavaScript values, except primitives, are objects.
Object Literals
var emptyObject = {};
Object Constructor
var person = new Object();
Attention!
setTimeout ( expression, timeout );
Call function after specific miliseconds
Change content after 1 sec
setInterval ( expression, timeout );
keeps triggering expression regularly
Change content afte every 500 ms
IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined.
(function () {// logic here }) ();
A closure is the combination of a function and the lexical environment within which that function was declared.
function User(name){ var displayName = function(greeting){ console.log(greeting+' '+name); } return displayName; } var myFunc = User('Kartik'); myFunc('Welcome '); //Output: Welcome Kartik myFunc('Hello '); //output: Hello Kartik
In this code, We have an outer function User() which returns an inner function as displayName(), The inner function will have access to the variables in the outer function scope, even after the outer function has returned.
find out all the JS libraries and framework here