Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JavaScript Interview Questions and Answers

Test your skills through the online practice test: JavaScript Quiz Online Practice Test

Related differences

Ques 16. What type of variables are in Javascript?

Must declare variables before they’re used in the program
Declare at the top of the program & terminate each statement with ‘;’
Intialize variables when appropriate
Local variables (declared within a function) destroyed after function exit.
Can only be accessed within the function

Example – Note Assignments
var candyBarPrice = 2.50;
var taxRate = .075;
var candyBarsPurchased;

Is it helpful? Add Comment View Comments
 

Ques 17. What is Assignment Operator in Javascript?

Assignment ‘looks like’ equal sign but does NOT behave like it

subTotal = subTotal + 1.50

subTotal ‘is assigned the value’ that is currently in subTotal plus the value of 1.50

Is it helpful? Add Comment View Comments
 

Ques 18. What is Expression in Javascript?

An expression is a statement that describes a computation.
Usually look like algebra formulas
total = subTotal * taxRate
Operators (+, -, *, /, etc.) have different levels of precedence, similar to algebra
Don’t rely on it! For clarity, use parentheses.

Is it helpful? Add Comment View Comments
 

Ques 19. Explain String in Javascript?

Strings are sequences of keyboard characters enclosed in quotes
“Hello World” or ‘Hello World’

Variables can hold strings
var greeting = “Hello World”

String can be empty, i.e., contain no characters
var myAnswer = “”

Use ‘\’ (escape symbol) to ‘type’ prohibited characters
\b for backspace, \n for newline, \t for tab, \” for double quote.

Is it helpful? Add Comment View Comments
 

Ques 20. What is Date class in Javascript? Please explain.

to create a Date object, use new & supply year/month/day/… as desired

today = new Date(); // sets to current date & time

newYear = new Date(2002,0,1); //sets to Jan 1, 2002 12:00AM

methods include:

newYear.getYear() can access individual components of a date
newYear.getMonth()
newYear.getDay()
newYear.getHours()
newYear.getMinutes()
newYear.getSeconds()
newYear.getMilliseconds()

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook
JavaScript vs JqueryJavaScript vs VBScriptJavaScript vs TypeScript