Important JavaScript Questions and Answers
In this Article we are trying to provide most important JavaScript Questions and Answers mcqs, (set 4) which mostly used for interviews and to developing the software. For further we will upload article as well as soon.
JavaScript is most powerful and Latest technology support to Linux, Unix,windows etc. we hope this article would be very helpful . So after reading the article Visit our Facebook Page and give feedback in comments. because it important for us. at the end of page by clicking next button read more articles..
- Define function hositing in javaScript..??
In the JavaScript moving declarations to top is called hoisting. There are two ways to creating functions in JavaScript. The One is Function Declaration and Function Expression. Now define below
Function Declaration: A function with the specific parameters is known as function declarations. To create a variable in JavaScript is called declarations,
hoisted(); // logs “foo”
function hoisted()
{ console.log(‘foo’); }
Function Expression: A function which is created by using as expression is called function expression.
const getRectArea = function(width, height) {
return width * height;
};
console.log(getRectArea(3, 4));
// output is : 12
- Explain Arrow function in JavaScript.??
A short way to write function expression in ES6 or above. It cannot be used as a constructor and does not support super, argument , or new target keyword. Its look like as
hello = () => {
return “Hello World!”;
}
- Define what are import and export ..???
Theexport
statement is used when creating JavaScript modules to export live bindings to functions, objects, or primitive values from the module so they can be used by other programs with the import statement.
Imports allow taking only some specific variables or methods of a file. See it with example..
//index.js
import adress,age from ‘./person’;
console.log(adress);
console.log(age);
//person.js
let adress =’Sharad’, occupation=’developer’, age =14;
export { adress, age};
- How to import all exports of a file as an object in JS..??
We can simply access the exported variables or methods using dot (.) operator of the object in javaScript. See with example..
objectname.member1;
objectname.member2;
- Define “use Strict”???
"use strict"
method define that JavaScript code should be executed in “strict mode”..
“use strict”;
myFunction();
function myFunction() {
x =2.34; // This will also cause an error because x is not declared
}