- Inline Script
- External Script
Example of Inline Script :
Example of External Script :
and externalFile.js contains following code:
Both approaches will give the same result and there is no much difference.
Best Approach is using External Files. Below are the reasons :
- External files can be cacheable and they can increase the page load time.
Declaration Example :
Definition Example :
temp = 5;
To make you understand better, see the below code :
var temp; // declaration
temp = 5; // definition
var abc = 3; //declaration and definition included
var intValue = 50;
var mixedValue = intValue + strValue;
However, a point to be noted here is that, If we add a number and string we get result as a String but if we subtract then we get an Integer value.
What is the difference between “==” and “===” ?
“==” converts the both operands to same type before comparing which is known as Type Coercion.
“===” doesn’t convert to same type before comparing.
In simpler words, “==” checks the value comparison but will not check type but “===” checks both value and type comparison.
The Name itself tells us that a Function which is executed immediately after it is defined.
Immediate Function Syntax :
console.log('This is a Immediate Function');
|Call By Value||Call By Reference|
|Actual value is not modified on changing dependent variable.||Actual value is modified on changing dependent variable.|
|Actual and Dependent variable are present in different memory locations.||Actual and Dependent variable are present in same memory location.|
|In case of function, changes in variable passed will not affect the actual value.||In case of function, changes in variable passed will affect the actual value.|
Thanks for visiting InterviewQuestionsBlog !!!!
Related Articles :