Photo by Aaron Burden on Unsplash
Test Your JavaScript Skills : ES8/ES7 (JavaScript 2017/16) - 46
Part 46
Table of contents
Introduction
Namaste, In this blog I will discuss 12 code scenarios on Javascript .
Identify the output of the below program
let city = { "delhi":1000, }; let obj = Object.getOwnPropertyDescriptors(city); console.log(obj.delhi.configurable);
a.false
b.true
c.delhi
d.error
e.1000
Answer:b
Reason:The configurable is true for the current property.
Identify the output of the below program
let city = { "delhi":1000, }; let obj = Object.getOwnPropertyDescriptors(city); console.log(obj.delhi.writable);
a.true
b.false
c.delhi
d.error
e.1000
Answer:a
Reason:The writeable is true for the current property.
Identify the output of the below program
console.log("ram".padStart(4,0));
a.0ram
b.0000am
c.ram
d.error
e.undefined
Answer:a
Reason:The padding is done at start with 0 where the size is 4 characters.
Identify the output of the below program
console.log("ram".padEnd(5,0));
a.ram00000
b.ram0000
c.ram00
d.undefined
e.error
Answer:c
Reason:The padding is done at end with 0 where the size is 5 characters.
Identify the output of the below program
console.log("ram".padStart(3,0));
a.ram
b.000ram
c.0ram
d.ram0
e.undefined
Answer:a
Reason:The output is ram.
Identify the output of the below program
let a=10; let b=3; let c = a**b; console.log(c);
a.30
b.100
c.1000
d.error
e.10
Answer:c
Reason:By exponent computation the result is 1000.
Identify the output of the below program
let names = ["ram","hari","gopi","ramesh"]; console.log(names.includes("mahesh"));
a.true
b.false
c.0
d.5
e.undefined
Answer:b
Reason:The string Mahesh is not found in names array.
Identify the output of the below program
let names = ["ram","hari","gopi","ramesh"]; console.log(names.includes("ramesh"));
a.0
b.3
c.undefined
d.false
e.true
Answer:e
Reason:The string ramesh exists in names array.
Identify the output of the below program
let city = { "delhi":1000, }; let obj = Object.getOwnPropertyDescriptors(city); console.log(obj.delhi.key);
a.delhi
b.1000
c.undefined
d.error
e.true
Answer:c
Reason:The key is undefined for the current property.
Identify the output of the below program
let city = { "delhi":1000, }; let obj = Object.getOwnPropertyDescriptors(city); console.log(obj.delhi.value);
a.delhi
b.true
c.false
d.1000
e.error
Answer:d
Reason:The value of the current property is 1000.
Identify the output of the below program
let cities = ['Bangalore', 'Mumbai', 'Hubli', 'Mysore','Pune', 'Kolkata']; console.log(cities.includes('Hubli', 4));
a.0
b.2
c.undefined
d.false
e.true
Answer:d
Reason:The string hubli exists before index 4 in array cities.
Identify the output of the below program
let cities = ['Bangalore', 'Mumbai', 'Hubli', 'Mysore','Pune', 'Kolkata']; console.log(cities.includes('Pune', 4));
a.0
b.2
c.undefined
d.false
e.true
Answer:e
Reason:The string Pune exists at index 4 in array cities.