“Wawancara JavaScript” Kode Jawaban

Wawancara JavaScript

1) What are the Various data tyes in javaScript

var age = 18;                           // number 
var name = "Jane";                      // string
var name = {first:"Jane", last:"Doe"};  // object
var truth = false;                      // boolean
var sheets = ["HTML","CSS","JS"];       // array
var a; typeof a;                        // undefined
var a = null;                           // value null

2) What is callback 
// 
// callback function is a function passed into another function as an argument.
// Don't call me, I will call you.

function greeting(name) {
  alert('Hello ' + name);
}

function processUserInput(callback) {
  var name = prompt('Please enter your name.');
  callback(name);
}

processUserInput(greeting);

3) Difference between Function Declaration vs Function Expression?

// Function Declaration
// Declare before any code is executed.
// You cade can run because, no call can be called until all expression is loaded 
// Declated as a seprate statement within the main JavaScript code

console.log(abc())

function abc(){
return 5;
}

// Function Expression
// Created when the execution point reaches it. can be used only after that.
// created inside an expression or some other construct
 
var a = function abc(){
return 5;
}
console.log(a)


4) What is cookies, sessionStorage, localStorage.

// cookies in created by a server and stored on client-side.
// it is used to remember information for later, so It can give better recommendation for the user.

// SessionStorage and localStorage are similar except

// SessionStorage data is cleared when the page session ends.

// localStorage data stay until the user manually clears the browser or until your web app clears the data.

5) What are Closures

// Is a feature where the inner function has access to the outer function variable.
// The inner function inner_func can access its variable 'a' and the outer variable 'b'. 


function outer_func()
{
	var b = 10;
	function inner_func(){
	var a = 20;
	console.log(a+b);
}
return inner;
}


6) what are the Import and Export in javaScript

// You can share functions, objects, or primitive values from one file by using export and access it from a different file by using import.

// Export 
export const name = "Jesse";

// or 

const name = "Jesse";
export {name};

 // or 

const message = () => {
const name = "Jesse";
return 'My name is' + name ';
};
export default message;


// import
import { name, age } from "./person.js";

// or 

import message from "./message.js";


7) What is the Difference between Undefined, undeclared, Null

// undefined means that the variable has not been declared, or has not been given a value.
// Undefined is used for unintentionally missing values.
var name;
console.log(name);


// Undeclared means the variable does not exist in the program at all.
console.log(name);


// Null used for intentionally missing values. It contains no value.

8) How to remove Duplicates from javaScript Array?

// By using the filter method

let chars = ['A', 'B', 'A', 'C', 'B'];

let uniqueChars = chars.filter((c, index) => {
    return chars.indexOf(c) === index;
});

console.log(uniqueChars);

// [ 'A', 'B', 'C' ]


Yafet Segid

Pertanyaan Wawancara JavaScript

var obj = {
    name:  "vivek",
    getName: function(){
    console.log(this.name);
  }
}
        
obj.getName();
Green Team

Quetions Wawancara JavaScript

var symbol1 = Symbol('symbol');
Prajwal Kharat

mengajukan pertanyaan JavaScript di konsol

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question("What do you think of node.js? ", function(answer) {
  console.log("Thank you for your valuable feedback:", answer);

  rl.close();
});
Terrible Turkey

Pertanyaan wawancara JS

function addFourNumbers(num1,num2,num3,num4){
  return num1 + num2 + num3 + num4;
}

let fourNumbers = [5, 6, 7, 8];


addFourNumbers(...fourNumbers);
// Spreads [5,6,7,8] as 5,6,7,8

let array1 = [3, 4, 5, 6];
let clonedArray1 = [...array1];
// Spreads the array into 3,4,5,6
console.log(clonedArray1); // Outputs [3,4,5,6]


let obj1 = {x:'Hello', y:'Bye'};
let clonedObj1 = {...obj1}; // Spreads and clones obj1
console.log(obj1);

let obj2 = {z:'Yes', a:'No'};
let mergedObj = {...obj1, ...obj2}; // Spreads both the objects and merges it
console.log(mergedObj);
// Outputs {x:'Hello', y:'Bye',z:'Yes',a:'No'};
Strange Sable

Pertanyaan Wawancara JavaScript

var currentDate = new Date();
var day = currentDate.getDate();
Var month = currentDate.getMonth() + 1;
var monthName;
var hours = currentDate.getHours(); 
var mins = currentDate.getMinutes(); 
var secs = currentDate.getSeconds(); 
var strToAppend;
If (hours >12 )
{
    hours1 = "0" + (hours - 12);
strToAppend = "PM";
}
else if (hours <12)
{
    hours1 = "0" + hours;
    strToAppend = "AM";
}
else
{
    hours1 = hours;
    strToAppend = "PM";
}
if(mins<10)
mins = "0" + mins;
if (secs<10)
    secs = "0" + secs;
switch (month)
{
    case 1:
        monthName = "January";
        break;
    case 2:
        monthName = "February";
        break;
    case 3:
        monthName = "March";
        break;
    case 4:
        monthName = "April";
        break;
    case 5:
        monthName = "May";
        break;
    case 6:
        monthName = "June";
        break;
    case 7:
        monthName = "July";
        break;
    case 8:
        monthName = "August";
        break;
    case 9:
        monthName = "September";
        break;
    case 10:
        monthName = "October";
        break;
    case 11:
        monthName = "November";
        break;
    case 12:
        monthName = "December";
        break;
}

var year = currentDate.getFullYear();
var myString;
myString = "Today is " + day +  " - " + monthName + " - " + year + ".<br />Current time is " + hours1 + ":" + mins + ":" + secs + " " + strToAppend + ".";
document.write(myString);
Bewildered Buzzard

Jawaban yang mirip dengan “Wawancara JavaScript”

Pertanyaan yang mirip dengan “Wawancara JavaScript”

Lebih banyak jawaban terkait untuk “Wawancara JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya