Thinking in a Javascript
When only static website was created with Html, CSS, but then it was not interactive, it was not effective. So javascript is used to make a website interactive.
Truthy and Falsy Value for Javascript
Truthy Value.
Truthy value- In javascript, if we assign a value to a variable, we impose a condition. If a value is found, then that condition is Truthy value. Here are some examples of truthy value.
- ’0'
- ‘ ’
- [],{}
If an element is given in a variable, it is called truthy.
Falsy Value.
If no value is assigned to any variable in Javascript, then that condition will usually return a falsy value.
- 0
- “”
- undefined
- null
- NaN
- false
Null vs Undefined.
Undefined
It means a variable declared, but no value has been assigned a value.
For Example.
var demo;
alert(demo); //shows undefined
Null
whereas, null in JavaScript is an assignment value. You can assign it to a variable
For Example.
var demo = null;
alert(demo); //shows null
Double equal (==) vs Triple equal (===), implicit conversion
Double equal (==)
If you give a condition with double equal == it will be true or false on the value. But the values here will not check which data types.
Triple Equal (===)
If you write a condition with triple equal ===, first you have to confirm the value of the data types, first come to its condition.
Scope, Block Scope. Clouser Details of it
When working with scope in javascript, you usually have to talk about 3 types of scope. The scope is discussed below.
1.Local Scope
Variables declared inside the functions become local to the function and are considered in the corresponding local scope.
2. Global Scope
The area outside all the functions is considered the global scope and the variables defined inside the global scope can be accessed and altered in any other scopes
Clouser
If there is another function inside one of the functions, then the second function, if we do, then the function creates a clouser environment.
The window Object.
The window object is supported by all browsers. It represents the browser's window. Even the document object is a property of the window object.
window.document.getElementById("hello world")
Asynchronous Javascript setTimeout
In Javascript, codes usually work synchronously one after the other, but if a setInterval timer is set in the code, then usually Asynchronous system-wise working.
Difference between bind,call and apply
.Bind()
The function of .bind is to set all the properties of the methods inside any of the above objects, then if we prepare another object below then we want to apply some of the above methods to the methods inside it, then is created and we have to set the value by typing .bind.
.Call ()
.call works just like a .bind, but with a few exceptions, because if you want to use the above object and method on another object, or if you want to do it, you can usually simply call the new ready object.
.Apply()
The application of .apply is the same as .bind and .call, but one thing is that when we put more than one parameter inside, we have to give the parameters in the form of an array using commas with the name of the object.
Event Bubble.
By default, events bubble in JavaScript. Event bubbling is when an event will traverse from the most inner nested HTML element and move up the DOM hierarchy until it arrives at the element which listens for the event. This move is also popularly known as Event Propagation or Event Delegation.