article

javascript interview questions - part 2

[WHAT]

  1. ] here is a list of some javascript interview questions(31),
    1. ] ADD this compiled from a number of sources, along with my answer,and their(the original sites) answer
  2. ] Although these are relatively simple questions,
    1. ] working through them was beneficial for me as I stumbled upon a few of them because my native js tongue is jquery and
  3. ] i like the (softball) easy coding questions BUT if I was interviewing someone for a js programming position,
    1. ] I think just having them submit a code sample along with their application would be a much quicker
    2. ] EXAMPLE REQUEST - please include a sample of a javascript function that you wrote that demonstrates ( ] use of an array, ] creating the array and accessing elements of the array )
    3. ] YES i realize that the code submitted could be c+p from 'anywhere' but ...

[WHY]

  1. ]

[WHERE]

  1. ] READ THE FULL ARTICLE
    1.  http://www.codeproject.com/Articles/620811/Latest-JavaScript-Interview-Questions-and-Answers

[WHEN]

[EXAMPLE]

[HOW-TO]

[REFERENCE]

  1. ] http://www.codeproject.com/Articles/620811/Latest-JavaScript-Interview-Questions-and-Answers
    1. by  Vikas Ahlawat 2013-08-26
    2. src = g.qry "js interview questions", result # 2
  2. ] javascript-interview-questions-part-1
    1. by
    2. src =

 

  1. ]  what is javascript
    1. ] programming language, loosely typed, uses c like syntax, interpreted, based upon ?lisp? ] creator Brendan Eich(@netsape), started on the web circa 1996, to manipulate html/dom in the browser, grew exponentially, ubiqutious,
    2. ] Ans:JavaScript is a scripting language most often used for client-side web development.
  2. ] what is the difference between javascript and jscript?
    1. ] jscript is msft implementation of the javascript specification(ecmascript), each brower vendor creates it own implementation of the ecmascript standard (current v= ?262.5?)
    2. ] Ans:Both JavaScript and Jscript are almost similar. JavaScript was developed by Netscape. Microsoft reverse engineered Javascript and called it JScript.
  3. ] how do we add javascript onto a web page?
    1. ] write a js file then link that file to your page<head> <script type="text/javascript "src="path"/> </head> OR before the closing body tag // ] write a js script inside of the head of your page // ] write a js script inline inside the body of the page using <script> tags
    2. ] for short single use scripts put in head of your page, for larger scripts, write a js files and link
  4. ] is javascript case sensitive?
    1. ] yes - js is very sensitive,
    2. ] yes - getElementById IS NOT the same as getElementByID
  5. ] What are the 'types' used in javascript?
    1. ] String, Number, Math, Array, Function, Boolean, Object, RegEx ?? ( Null, Undefined ) Array type ??
    2. ] Ans:String, Number, Boolean, Function, Object, Null, Undefined.
  6. ?? ] What art the boolean operators supported by the js AND operator &&
    1. ] x < 10 &&  ( >,<, ===, !===, )
    2. ] OR operator || NOT operator - !
  7. ] What is the difference between == and ===
    1. ] == can cause problems because ..., always use ===
    2. ] == checks for equality only, === checks for equality and type
  8. ] how to access the value of a textbox using javascript?
    1. ] var textBoxValue = getElementById('textboxid').value; // document.getElementById
    2. ] document.getElementById(...) //
  9. ] What are the ways of making comments in js?
    1. ] // single line, /* multi line */
    2. ] // line comments /* block comments */
  10. x] how will you get the checkbox status, wether it is checked or not?
    1. ] if (document.getElementById('checkBox1').checked === 'checked' ) {alert("checked");}else{alert("not checked");} // value = true, // ] $("checkBox").val('true')
    2. ] document.getElementById('checkBox1').checked returns true OR false
  11. ] how to create arrays in javascript?
    1. ] var cats = new Array("chester","harly","carly"); // object literal var cats = ["chester","harly","carly"] // var cats = new Array(); cats[0] = "chester";
  12. ] If an array with name as "names" contain three elements, then how will you print the third element of this array?
    1. ] alert(names[2]);
    2. ] Ans: Print third array element document.write(names[2]);
  13. ] How do you submit a form using JavaScript?
    1. ] document.getElementById('idForm').submit() // $('idForm').submit()
    2. ] Ans:Use document.forms[0].submit();
  14. ] what does the 'isNan' function do?
    1. ] determines if a value is a Number type or not
    2. ] It returns true if the argument is not a number.
  15. ] What is the use of Math Object in JavaScript?
    1. ] Math is a native js object that contains a collection of Mathematical functions you can use in your program, var randomNumber = Math.Random();
    2. ] The math object provides you properties and methods for mathematical constants and functions
  16. ] What do you understand by this keyword in JavaScript?
    1. ] this is a js keyword, you can use 'this' as a shortcut to reference the 'currently in scope' object's properties and methods, its invaluable b/c it enables you to id which option (of any number of options) that is currently active/selected by user
    2. ] Ans: In JavaScript the this is a context-pointer and not an object pointer. It gives you the top-most context that is placed on the stack. The following gives two different results (in the browser, where by-default the window object is the 0-level context):
    3. var obj = { outerWidth : 20 };
       function say() {
          alert(this.outerWidth);
      }
       say();//will alert window.outerWidth say.apply(obj);//will alert obj.outerWidth
  17. ) What does "1"+2+4 evaluate to?
    1. ] returns string "124", because "1" is a string, everything is treated as a string
    2. ] Ans: Since 1 is a string, everything is a string, so the result is 124.
  18. ] What does 3+4+"7" evaluate to?
    1. x] returns 77 because ...
    2. Ans: Since 3 and 4 are integers, this is number arithmetic, since 7 is a string, it is concatenation, so 77 is the result.
  19. ] How do you change the style/class on any element using JavaScript?
    1. ] document.getElementById('element').setAttribute("class","newClassName");
    2. ] document.getElementById(“myText”).style.fontSize = “10"; OR document.getElementById(“myText”).className = “anyclass”;
  20. X] Does JavaScript support foreach loop?
    1. ] no
    2. ] Ans: JavaScript 1.6(ECMAScript 5th Edition) support foreach loop,
  21. ] What looping structures are there in JavaScript?
    1. ] for, for each in, for in, for of, do while, while
    2. ] Ans: for, while, do-while loops
  22. ] What is an object in JavaScript, give an example?
    1. ] everything in js is an object, if were talking in the language itself, Number, Date, String, ... are all objects
    2. ] Ans: An object is just a container for a collection of named values:
      1. var man = new Object();
      2. man.name = 'Vikas Ahlawat';
      3. man.living = true;
      4. man.age = 27;
  23. ] How you will add function as a property in a JavaScript object? Give an example.
    1. ] man.showAge = function() {alert(this.age);};
    2. ]
  24. ] What is the similarity between the 1st and 2nd statement?
    1. 1st:- var myString = new String('male'); // An object.
    2. 2nd:- var myStringLiteral = 'male'; // Primitive string value, not an object.
    3. ] both create a new string object, the 2nd while classified as a Primitive, still has an object wrapper that gives you the String objects functionality (lenght, ...)   
Details Photos Edit more

Details

ID: 2618

NAME: javascript-interview-questions

DESCRIPTION: javascript interview questions ] by Vikas Ahlawat @CodeProject.com, src=g.qry(js interview questions), includes my answers, the answers

AUTHOR: article.author/s

EDITOR: article.editor/s

PUBLISHER: article.publisher/s

STATUS: Write

PRIORITY: -5

OWNER ID: 75

Content Photos Edit more

photos

page_photo

actions

Email Email-Owner SMS and