Sony Inerview Question&Ans
Sony Inerview Question&Ans
Ans: == and === both are comparision operators , we used to comparing 2 values.
== used comparing 2 values, if 2 values are same it will return true.
=== used to comparing both values and datatypes . if both statements equal
it will return true.
Map: map we used to in order to make the changes in array data . and map based on
condtion it will modify the element and finally it will give the result with same
length.
Filter: Filter it will return tre or false result, based on condition which element
is true that element is push to array.
function countOccurrencesOfA(inputString) {
inputString = inputString.toLowerCase();
let count = 0;
return count;
}
7.Take array store strings and print if a string having 'a' in it using async and
await?
Explanation>>>>>>> npx-- npx is a node package executor is come up with npm and it
is used for executing packages
wdio--- wdio is a webdriver io command line
interface and it is used to setup, configure , run , manage test suite and test
runner.
run---This is an sub command of the webdriver
io command line interface, used for running tests.
./wdio.conf.js --This file contain setting
such as test framework, browser capabilities, test file and other configuration
files.
As of now we not use sync method , we use async to handle Asynchronous operation.
Dependencies (dependencies):
a)Dependencies, often listed in a project's package.json file under the
"dependencies" field, are packages that are required for the application to run in
a production environment.
b) These packages are essential for the application's core functionality
and are installed when someone else installs or uses your package or application.
They are also installed when .
c)Examples of dependencies include web frameworks (e.g., Express.js),
database drivers (e.g., MongoDB driver), or utility libraries that your application
relies on to function.
Variables declared with var are function-scoped, meaning they are only
accessible within the function in which they are defined.
var variables are hoisted, which means that they are moved to the top of their
containing function or global scope during compilation.
They can be redeclared within the same scope without any errors.
javascript
function exampleVar() {
var x = 10;
if (true) {
var x = 20; // This reassigns the outer 'x'
console.log(x); // Outputs 20
}
console.log(x); // Outputs 20
}
let:
Variables declared with let are block-scoped, which means they are only
accessible within the block (e.g., if statement, for loop) in which they are
defined.
let variables are not hoisted, and they cannot be redeclared within the same
scope.
javascript
function exampleLet() {
let x = 10;
if (true) {
let x = 20; // This creates a new 'x' inside the block
console.log(x); // Outputs 20
}
console.log(x); // Outputs 10
}
const:
Variables declared with const are also block-scoped like let.
const variables, however, must be assigned a value when declared, and once
assigned, their value cannot be changed (they are constants).
Similar to let, const variables are not hoisted, and they cannot be redeclared
within the same scope.
function exampleConst() {
const x = 10;
if (true) {
const x = 20; // This creates a new 'x' inside the block
console.log(x); // Outputs 20
}
console.log(x); // Outputs 10
}
any entity having state and behaviour or properties and values is called as an
object.
in JavaScript object consist of properties and values (value can be of any
datatype),
property-value are separated by (:)
properties-values pair are separated by (,)
function A(){
var Detail={
'Name':"Kumar"
}
return Details;
}
function B(userdata){
console.log(userdata.Name)
}
B(A)
Function:
• It is the block of code
• Used to perform some specific task
• It is reusable
Types of functions
1. Standard function / function declaration
2. Function expression
3. IIF (Immediately Invocable Function)
4. Arrow function
Object:
any entity having state and behaviour or properties and values is called as an
object.
in JavaScript object consist of properties and values (value can be of any
datatype),
property-value are separated by (:)
properties-values pair are separated by (,)
var values=[1,1,2,3,4,3,5,6,7,6]
var result=[ ]
values.filter((element)=>{
if(result.include(element)==false){
result.push(element)
}
log(result)
20. . what are the ES6 features you have used in your project?
a)Class
b) Let and Const
c)Arrow function
d) Promise.
e) Template literals
The WDIO CLI is designed to simplify the process of setting up and running
WebdriverIO tests. It provides various commands and options for tasks such as test
configuration, test execution, test reporting, and more. Some common tasks you can
perform with the WDIO CLI include:
Test Configuration: You can use the WDIO CLI to initialize a new test project,
which sets up a basic project structure and configuration files for your tests.
Test Execution: The CLI allows you to run your WebdriverIO tests using different
configurations, browsers, and test suites. You can execute tests locally or on
remote WebDriver instances (e.g., Selenium Grid).
var ele=["tys","yantra","pvt"]
var str="programming"
var count=0
if (str[ i ]==str[ j ]) {
count++
}
if(j<i){
break
}
if (count>1) {
console.log(str [ i ]+"is"+count);
}
}
node js a back end javascript run time envionment and node js runs on javascript
engine then it will execute javascript code outside a browser.
28. Promise ?
Pending: The initial state, indicating that the operation is still in progress.
Fulfilled: The operation has completed successfully, and the promise now has a
result value.
Rejected: The operation has encountered an error, and the promise has a reason
for the failure.
Promises provide methods such as then() and catch() to handle the result or error
of an asynchronous operation in a more structured manner.