Cubedots
TCS Interview Questions and Answers
Q1. What is "use strict" in javascript
use strict is a directive in JavaScript that enforces stricter parsing and error handling.
It enables modern JavaScript features and disallows certain syntax that could lead to errors.
It must be placed at the beginning of a script or function.
It helps in writing more secure and optimized code.
Example: 'use strict'; var x = 010; // SyntaxError: Octal literals are not allowed in strict mode.'
Q2. What is API and hot to use.
API stands for Application Programming Interface. It is a set of protocols and tools for building software applications.
API allows different software applications to communicate with each other
API specifies how software components should interact
API can be used to retrieve data from a server or database
API can be used to integrate third-party services into an application
API can be accessed using HTTP requests
API documentation is important for understanding how to use it
Q3. How many types of array in js
There is only one type of array in JavaScript.
JavaScript has only one type of array, which can hold any type of data.
Arrays can be created using the array literal notation or the Array constructor.
Arrays have a length property that returns the number of elements in the array.
Arrays have various methods like push(), pop(), shift(), unshift(), splice(), etc.
Q4. What is promise in javascript
Promise is an object representing the eventual completion or failure of an asynchronous operation.
Promises are used to handle asynchronous operations in JavaScript
They are a cleaner alternative to callbacks
Promises have three states: pending, fulfilled, or rejected
They can be chained using .then() and .catch() methods
Example: new Promise((resolve, reject) => {...})
Q5. What is anonymous function
An anonymous function is a function without a name.
Declared using function keyword without a name
Can be assigned to a variable or passed as an argument
Used for one-time use or as a callback function
Example: const sum = function(a, b) { return a + b; }
Q6. How define variables in js
Variables in JavaScript are defined using the 'var', 'let', or 'const' keywords.
Use 'var' to declare a variable with function scope
Use 'let' to declare a variable with block scope
Use 'const' to declare a constant variable
Variables can be assigned a value using the '=' operator
Variables can be declared without assigning a value
Variables can be declared and assigned in the same statement
Q7. Difference between JS and ECMAScript
ECMAScript is a standard, while JavaScript is an implementation of that standard.
ECMAScript is a specification for scripting languages, while JavaScript is a programming language that implements ECMAScript.
ECMAScript is maintained by ECMA International, while JavaScript is maintained by the Mozilla Foundation.
ECMAScript is used as a basis for many other programming languages, while JavaScript is used primarily for web development.
ECMAScript is updated regularly, while JavaScr...read more
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month