1.Tell me about yourself
Offcourse my mock interview start with tell me about yourself?
not only for me, for everyone who attend the interview.
it is very important question asked by the interviewer to check your communication skill as well as your confident and the way you speaking.
2.form validation in js
Form validation in JavaScript is primarily achieved by intercepting the form's submit event, evaluating the user inputs against specific logic rules, and halting the submission using event.preventDefault() if errors are detected. While HTML5 offers native attributes like required and pattern, JavaScript allows you to build completely customizable error reporting interfaces and complex logical evaluations.
- By using DOM we can handle the input values and we can check the datas inserted by user to achieve validation by restrict the input format and check wheather the input field is empty or else it contain data and all done by using javascript DOM.
3.CSS version
CSS3 – Introduced a modular approach.
Features:
border-radius.
box-shadow.
text-shadow.
gradients.
transitions.
Animations.
transforms.
flexbox.
grid.
media queries.
new selectors.
these are the new things present in CSS3.
4.Difference between flex and grid.
Grid
Is a powerfull two dimensional layout used to align items in both rows and coloumns simultaneously like full page structure.
Flex
Is a one dimensional layout used to align items either in single rows or in coloumns direction.
5.What is Media queries
media queries are used to write a different style for different screen size to make our website responsive.
max-width.
min-width.
are used to write the different styles for different screen size.
6.Switch Statement.
The switch statement in JavaScript evaluates an expression and executes a block of code matching a corresponding case label. It serves as a highly readable, efficient alternative to an extensive if...else if...else chain when comparing a single value against multiple options.
if-else: Used to check multiple conditions (can be complex, ranges, logical expressions).
switch: Used to compare one variable against multiple fixed values.
if-else = flexible + powerful.
switch = simple + cleaner for fixed values.
7.Ternary operator.
The JavaScript conditional (ternary) operator is a compact, one-line shorthand for the traditional if...else statement. It is the only operator in JavaScript that accepts three operands: a condition, an expression to run if true, and an expression to run if false.
Syntax
condition ? expressionIfTrue : expressionIfFalse;
Condition: An expression that evaluates to a truthy or falsy value.
?: Separates the condition from the "true" outcome.
expressionIfTrue: Executed if the condition is truthy.
:: Separates the true and false outcomes.
expressionIfFalse: Executed if the condition is falsy.
8.Primitive and Non-primitive
In JavaScript, data types are broadly divided into two categories: primitive values (which represent a single, unchangeable value) and non-primitive values (which represent complex, mutable collections of data).
primitive values can store only single values in it and it is immutable in nature.
non-primitive values can store morethan one values or multiple values and it is mutable in nature.
9.What is Immutable.
In JavaScript, immutable means a value cannot be changed after it is created. When you alter an immutable value, JavaScript does not update the data in place; instead, it discards the old value and allocates a completely new value in memory.
- For example, using a string method like .replace() does not change the original string. It generates a fresh copy.
let name = "John Doe";
name.replace("John", "Jane"); // it create a new value Jane Doe in new memory location and allocates it to name variable.
console.log(name); // "John Doe" (The original string remains untouched)
10.truthy and falsy values in JS.
In JavaScript, truthy and falsy values determine how non-boolean data types are evaluated inside conditional structures like if statements or loops. When JavaScript expects a boolean but receives another data type, it applies implicit type coercion to force that value to evaluate to either true or false.
Truthy values are values that are evaluated to be true when used in a Boolean context. Simply put, any value that is not explicitly falsy is considered truthy.
Falsy values are values that evaluate to false when used in a Boolean. JavaScript has a fixed list of falsy values.
false
0 (and -0)
0n (BigInt zero)
"" (empty string)
'' (empty character)
`` (empty literals)
null
undefined
NaN
these are the questions asked in mock interview.
Top comments (1)
Useful