(2 de 5) What Is JavaScript and How It Works Under The Hood - Codementor
(2 de 5) What Is JavaScript and How It Works Under The Hood - Codementor
What is JavaScript
Let's talk about one of the most famous languages today, JavaScript, one of
three basic component (HTML, CSS & JS) of the web. Wikipedia says ( For
understanding purpose I will breakdown de nition in few parts)
For example
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 1/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
function Circle(radius) {
this.radius = radius;
}
Circle.prototype.area = function () {
var radius = this.radius;
return Math.PI * radius * radius;
};
Circle.prototype.circumference = function () {
return 2 * Math.PI * this.radius;
};
circle.area() // 78.53981633974483
circle.diameter() // Uncaught TypeError: circle2.diameter is not a function
Here radius is a Number which also inherits properties from Number thats why
it outputs "5" on circle.radius.toString()
It also supports High Order Functions, it means function can take other
function as input and return a function as output.
Multi-paradigm means, you can program in with various coding styles like
OOP or Functional or mix of both.
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 2/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
It has an API for working with text, arrays, dates and regular expressions,
but does not include any I/O, such as networking, storage, or graphics
facilities, relying for these upon the host environment in which it is
embedded.
JS have API for text, arrays etc, this mean JS can count elements in an array or
can pop something out from it but it can't perform an API call itself, yes you
read it right JS Engine doesn't do it, browser does.
Javascript is single threaded, it means it can execute one thing at a time, check
the gure given below, whenever there some operation like console.log or a
+ b it pushes it into the stack operates it and pop it out.
If it is function call then it puts the function in the stack operates it, pops
everything out, like shown below
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 3/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
var x = 2;
var y = 7;
var z = sum(x,y);
console.log(z);
Let's see a working example, for simplicity we use will console.log and time
setTimeout only.
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 4/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
setTimeout(function(){
console.log("a");
},1500)
console.log("d");
setTimeout(function(){
console.log("b");
},500)
setTimeout(function(){
console.log("c");
},1000)
That's all for Today. If you have any doubts or improvement, comment here or
message me!
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 5/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
10 SHARE
Mukul Jain
Web Lover | Full Stack Developer @ Innovaccer | 4 Year of Experiance
I have been programming for last 4 years, I love building things and help people to build. If
need help in debugging, building, refactoring codebase, adding new features or guidance,
feel free to ping me.
FOLLOW
Leave a reply
software developers
HIRE A DEVELOPER APPLY AS A DEVELOPER
Ramón Miklus
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 7/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
START A DISCUSSION
Anthony Gore
Are web components "the future" for the web platform? There are many
opinions both for and against. What is a fact, though, is that browser support
is emerging for web components and there are a growing number of tools and
resources for authors interested in creating and publishing web components
of their own.
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 8/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
A great tool for creating web components is Vue.js, and it's been made even
easier with the release of Vue CLI 3 andMORE
READ the new [@vue/web ...
Your email
SUBSCRIBE
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 9/10
9/12/2018 What is JavaScript and How it works under the hood | Codementor
Kamran Ahmed
Before we begin with this post, just to give you an idea about me and about
this roadmap; I have been doing the Fullstack Development for the past 5
years and currently working as a lead engineer at tajawal where I have to wear
many di erent hats. It is not only my hobby but also one of my job
responsibilities to keep an eye on the trends and to keep the other developers
well trained. I see a lot of confusion among the beginners (and experienced
alike) when it comes to staying up to date. I had lots of friends and emails
asking me for g ... READ MORE
https://www.codementor.io/mukuljainx/what-is-javascript-and-how-it-works-under-the-hood-8bqkes6r2 10/10