JavaScript Tricky Interview Questions

Below are the list of Best JavaScript Tricky Interview Questions and Answers
Type coercion is the process of converting value from one type to another (such as string to number, object to boolean, and so on)
By using Number.isInteger() function
str.trim() method is used to remove the white spaces from both the ends of the given string.
Syntax:
str.trim()
Return value: This method returns a new string, without any of the leading or the trailing white spaces.
You can use the following code to strip whitespaces from String in JavaScript:
<!DOCTYPE html>
<html>
<head>
<title>
How to remove spaces from
a string using JavaScript?
</title>
</head>
<body>
<h1 style="color: green">
Online Interview Questions
</h1>
<b>
How to remove spaces from
a string using JavaScript?
</b>
<p>
Original string is:
Online Interviews Questions
</p>
<p>
New String is:
<span class="output"></span>
</p>
<button onclick="removeSpaces()">
Remove Spaces
</button>
<script type="text/javascript">
function removeSpaces() {
originalText =
"Online Interviews Questions";
newText =
originalText.replace(/ /g, "");
document.querySelector('.output').textContent
= newText;
}
</script>
</body>
</html>
Output:

Related Interview Questions-
JavaScript Interview Questions
-
JavaScript Closure Interview Questions
-
Node JS Interview Questions with Express
-
AngularJs
-
Ajax Interview Questions
-
Aurelia Interview Questions
-
Backbone js Interview Questions
-
D3.js interview questions
-
Ecmascript 2017 Interview Questions
-
Emberjs Interview questions
-
ES6 Interview Questions
-
Ext js Interview Questions
-
Grunt js Interview questions
-
Gulp Js interview questions
-
Handlebars js interview questions
-
JQuery Interview Questions
-
JSON Interview Questions
-
Knockout js Interview Questions
-
Koa Js Interview questions
-
Less.js interview questions
-
Marionette js interview questions
Subscribe Our NewsLetter
Never Miss an Articles from us.
Featured Categories
- Common Interview Questions
- Python Flask Interview Questions
- NoSQL interview questions
- JQuery Interview Questions
- C programming interview questions
- AngularJS Interview Questions
- Node JS Interview Questions with Express
- JavaScript Interview Questions
- Core Java interview questions
- HTML Interview Questions
- Laravel interview questions
- Wordpress Interview Questions
- PHP Interview Questions