Skip to content
Interview Shortout
  • Home
  • Articles
  • PHP
  • Python
  • Java Script
  • MySQL
  • Magento
  • Startups
  • Other

Basic Java Script Interview Questions and Answers

Posted on March 15, 2018 By Dhananjay No Comments on Basic Java Script Interview Questions and Answers
Java Script

What is Javascript?
Javascript is a client-side scripting language, used to enhance webpage functionality and User Experience.

What is the importance of Javascript in Web Development and Web design?
Javascript provide additional functionality to HTML elements. It handles the DOM and content dynamically. Javascript is used by all the giant players in software industries like Microsoft, Google, Facebook, Amazon etc.

How can we define a variable in javascript?
We can define a variable in javascript using ‘var’ keyword. for example :


var userName = 'Vishal Agrawaal';

What are the methods to return output in javascript?
We use alert(),console.log() and document.write() to display output in javascript.

What is an alert?
Alert is a dialog box to display some warning or error.It displays a message on dialogue and a close button or OK button by default.

How to get a value by the ID of the element?
We can find the value by using Javascript function
var employee_name = documenst.getElementById(‘element_id’).value;

What is DOM?
The HTML DOM model is a tree of Objects and Objects are created by HTML the elements when page loaded.It allow us to acces the content and allow us to manipulate the HTML elements properties and attributes dynamically using Javascript or other script.

What is event?
An event is an action that takes place followed by any DOM activity or manipulation. Javascript provides a vast range of events that helps to create interactive interfaces in HTML. For example : onchange,onclick,onblur,onfocus,onmouseover,onkeypress,onkeyup,onmouseout,onload ect.

How to create a function in Javascript?
Syantx to create a function in javascript:


function myFunction(){
//function logic goes here
}

Can JavaScript replace PHP or JSP or ASP?
Never, Not comparable. Javascript is a client-side scripting language whereas PHP and other are the server-side scripting language. So there is no any reason for replacement.

How to define an array in Javascript?
Defining an array in javascript is similar to any other language:


var students=['Ram','Vishal','Rahul','Kallu','Ballu','Lallu'];

How to handle date in javascript?
Javascript provides a constructor Date(). We can use Objects created by Date() and can Handle dates.For example:


var date = new Date();
var today = date.getDay();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();

How to anver an array into an string in Javascript?
We have an array :


var cars = ["BMW", "Benz", "Toyota", "Ford"];
var carString= car.toString();

and result will be :BMW,Benz,Toyota,Ford .

What is the functionality of pop() in js?
pop() is a standard method in javascript and it removes the last element of an array when we apply.
for example, we can apply it on cars :


cars.pop();

Now cars array will be : [“BMW”, “Benz”, “Toyota”];

What is the functionality of push() in js?
pop() is a standard method in javascript and it adds an element at the end of an array when we apply.
for example, we can apply it on cars :


cars.push("FORD");

Now cars array will be : [“BMW”, “Benz”, “Toyota”, “Ford”];

What is the functionality of splice() in js?
splice() added element/s at the particular index of an array and can remove some elements form the index. It can be used to relace some element in the array.


var cars = ["BMW", "Benz", "Toyota", "Ford"];
fruits.splice(1, 0, "Ferari");

Resulting array : [“BMW”, “Ferari”,”Benz”, “Toyota”, “Ford”];
First parameter is the index of the elemnet where the new elemnet will be added and second is the number of elements will be removed from that index.

How to apply a for loop in an array in Javascript?
Example of for loop in javascript:


var text='';
for (var i = 0; i < cars.length; i++) {
text += cars[i] + "
";
}
alert(text);

Post navigation

❮ Previous Post: WordPress Advance Interview Questions and Answers
Next Post: JSON Interview Questions and Answers ❯

Leave a Reply Cancel reply

You must be logged in to post a comment.

Doglapan

Recent Posts

  • Captable for Startups?
  • What is chat GPT?
  • All about Indexing in MySQL
  • Exploring the Growth and Future of Fintech Companies in Indian Startup Culture
  • Angel Investors in the Indian Startup Ecosystem: Understanding their Characteristics, Benefits and Role

Popular

AJAX artificial intelligence CakePHP Career Certifications CodeIgniter COVID Database Data Science DBMS DevOps Django Drupal ES6 Google Analytics HR Internship Interview Java Script jQuery Magento MVC MySQL PHP reactjs Risk Management Startups Training Visual Basic

Categories

  • AJAX
  • AJAX Interview Questions
  • Android
  • Articles
  • Artificial Intelligence
  • Banking
  • Big Data
  • Cake PHP Interview Questions
  • CakePHP
  • Career Guide
  • Certifications
  • CI/CD
  • Codeigniter Interview Questions
  • Codeigniter4
  • CSS
  • Data Science
  • DBMS
  • DevOps
  • Drupal
  • ES6 Interview Questions
  • Fresher Interview
  • Google Analytics
  • Gov Job
  • HR Interview
  • HTML
  • Internship
  • Interview
  • Java Script
  • jQuery
  • jQuery Interview Questions
  • JSON
  • Magento
  • MVC
  • MySQL
  • MySQL Interview Questions
  • OOPS
  • PHP
  • PHP Interview Questions
  • Python
  • Python Interview Questions
  • Reactjs Interview Questions
  • Resume
  • SEO
  • Startups
  • Visual Basic
  • WordPress
  • Wordpress Tutorial

Resources

  • Home
  • Paid Guest Post
  • About
  • Contact
  • Privacy Policy
  • DCMA
  • Home
  • Paid Guest Post
  • About
  • Contact
  • Privacy Policy
  • DCMA

Copyright © 2023 Interview Shortout.

Theme: Oceanly by ScriptsTown

Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}