JS, CSS, HTML Interview Questions Flashcards

1
Q

What is JavaScript?

A

JS is a client-side(front-end) and server-side(back-end) scripting language

JS is an OOP language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Enumerate the differences between Java and JavaScript

A

As far as I know Java is to JavaScript as pool is to pool table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the JS data-types?

A
object
number
string
boolean
null
undefined
symbol
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the use of the NaN function?

A

Checks to see if a something is a number and returns a boolean value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which is faster, JS or an ASP script?

A

JS will be faster if you compare its client-side aspect to the ASP since it is server-side and will run slower

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is negative infinity?

A

the largest negative number possible

it can be derived by dividing any negative number by 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Is it possible to break JS code into several lines?

A

Yes you can use an \n at the end of a line to create a break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which company developed JS?

A

Netscape by Brendan Eich

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are undeclared and undefined variables?

A

Undeclared: undeclared variables are those that do not exist in the code

Undefined: variables that have been declared but not given a value yet

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are global variables? How are these variables declared?

A

Global variables are declared with the var keyword and are accessible anywhere in the code
meaning they are without scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a prompt box?

A

A prompt box is a box that allows the user to enter input by providing a text box

A label and box will be provided to enter data into

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the ‘this’ keyword in JS?

A

“this” refers to the object from where it was called

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the working of timers in JS?

A

Timers are used to execute a specific piece of code at a set time or to repeat on a specific interval

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which symbol is used for comments in JavaScript?

A

/* for multi-line comments */

// for single line comments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between ViewState and SessionState?

A

‘ViewState’ is specific to a page in session

SessionState is specific to user-specific data that can be accessed across all web application pages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the === operator?

A

Strictly equals and it looks at whether two pieces of data are identical in type and value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How can you submit a form in JS?

A

document.form[0].submit()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Does JS support automatic type conversion?

A

yes, JS does support automatic type conversion

truthy and falsy values are good examples of this in practice

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How can the style/class of an element be changed?

A

get the element from the DOM and either change the style property or change the className property

20
Q

How to read and write a file using JS?

A

Using JS extensions

Using a web page and Active X objects

21
Q

What are all the looping structures in JS?

A

For loop
while loop
for in loop
Do while loops

22
Q

What is Variable typing in JS?

A

it means JS will figure out what type of data you have and make the necessary adjustments so you don’t have to redefine your different types of data

It does this through type conversion

23
Q

How can you convert the string of any base to an integer in JS?

A

The parseInt() function is used to convert numbers between different bases.

24
Q

What is the difference between == and ===?

A

== is not strict equality and so it allows for type conversion to take place unlike string equality with ===

== only checks for value
=== checks value and data type
25
Q

What would be the result of 3 + 2 + “7”?

A

57

26
Q

How to detect the operating system on the client machine?

A

In order to detect the operating system on the client machine, the navigator. Platform string (property) should be used.

27
Q

What do you mean by NULL in JS?

A

The NULL value is used to represent nothing. However, it is often the case where null is assigned as a value to something that’s value will change later. It can act almost like a empty parking lot.

28
Q

What is the function of the delete operator?

A

The delete operator is used to delete the the property and the value of an object

29
Q

What is JSON?

A

JavaScript Object Notation

standard text based format that is used to represent structured data based on JS object syntax.

Commonly used to send data between a client and a sever

30
Q

What is the undefined value in JS?

A

undefined is also nothing and it can mean multiple things as it is thought of more as a the program telling you the value of something is nothing

variable doesn’t exist
variable has no value
property doesn’t exist
etc etc

31
Q

What are all the types of pop-up boxes in JS?

A

alert

confirm and

prompt

32
Q

What is the use of Void(0)?

A

it is used to prevent the page from refreshing

used to call another method without refreshing the page

33
Q

What is the data type of variables in JS?

A

all variables are objects

34
Q

What is the difference between an alert box and a confirmation box?

A

an alert box displays only one button “ok”

a confirmation box displays two buttons “ok” and “cancel”

35
Q

What are escape characters?

A

Escape characters or backslashes are used when working with special characters like single quotes, double quotes, apostrophes, and ampersands.

Place the backslash before the characters to make it display

36
Q

What are JS cookies?

A

Cookies are the small test files stored in a computer, and they get created when the user visits the websites to store information they need. Examples could be username details and shopping cart info from previous visits.

37
Q

What does pop() method do in JS?

A

The pop method will remove the last element from an array and returns the removed element.

38
Q

Does JS have concept level scope?

A

No. A variable declared inside the function has scope inside the function

39
Q

What are the disadvantages to using innerHTML in JS?

A

Content is replaced everywhere

It poses a security risk as well

40
Q

What are break and continue statements?

A

Break: exits from the current loop

Continue: continues to the next statement in the loop

41
Q

What are the 2 basic data types in JS?

A

Primitives

Reference types (array, function, object)

42
Q

How can generic objects be created in JS?

A

since js is not strictly a typed language we don’t need to write generic objects

43
Q

What is the use of a type operator?

A

typeof is an operator used to return a string description of the type of a variable

44
Q

Which keywords are used to handle exceptions?

A

Try

Catch

Finally

45
Q

Which keyword is used to print the text on the screen?

A

Document.Write(“word”) is used to print the text “word” on the screen.