Simple Interview questions

Multiple simple questions on javaScript

by sendil J

HTML

<textarea id='output' readonly style="width:100vh;height:50vh;"></textarea>

JavaScript

var answer; // The value of this variable is undefined

//answer = typeof(null);// The value of this answer is object
if (answer == undefined) {
  answer = 'undefined value';
}
var result = document.getElementById('output');
result.innerHTML = answer;

// Pass input text value to another HTML page from Home page through query string, localStorage and cookies.

var obj = {};// check an variable is not null and its a object
var arr = [2, 1, 8] // sort this array without using sort()
var Arr = [2, 1, 8] // sort this array without using duplicate array
var obj = { // print only the keys of this object tree.
  key1: '2',
  key2: [{
    keya: '1',
    keyb: '2',
    key2: [{
      keyaa: '1',
      keybb: '2'
    }]
  }]
}