let a = { "result": { "id": 458776166, "name": "Indore to Bhopal Volvo Bus", "number": "INDBPL1300", "service_name": "Chartered Bus", "origin_id": 512, "destination_id": 184, "op_schedule_id": 647926, "travel_date": "2022-05-03", "travel_id": 2251, "travels_name": "Chartered Bus", "route_id": 23, "route_map_id": null, "available_seats": 80, "description": "", "dep_time": "13:00", "duration": "04:00", "arr_time": "17:00", "bus_type": "2+2, Benz A/C Seater, Non-AC, Non-Video", "bus_type_id": 284, "cost": "SS:470.48", "can_cancel": true, "cancellation_time": 0, "cabin_layout": false, "status": "Update", "is_service_tax_applicable": true, "helpline_number": null, "amenities": "[\"Bathroom\",\"Blankets\",\"Bus Hostess\",\"Charging Point\",\"Coffee\",\"Croissants\",\"Emergency exit\",\"Facial Tissues\",\"Fire Extinguisher\",\"Food\",\"Free Pickup\",\"Hammer (to break glass)\",\"Headsets\",\"Live Bus Tracking\",\"Movie\",\"Newspaper / Magazine\",\"Personal TV\",\"Pillow\",\"Reading Light\",\"Snacks\",\"Soft drink\",\"Towel\",\"Water Bottle\",\"WiFi\",\"Panic\",\"Security guard\",\"Lady attendant\",\"CC Camera\",\"RO Filter\",\"Ladies Toilet\",\"Welcome Note\",\"Hand Sanitizer\",\"Wet Wipes\",\"Mount Freshner\",\"Bus Host\",\"First Aid Box\",\"Vomiting Bag\",\"M Ticket\",\"Toilet\",\"Driver/ Conductor with masks\",\"Disinfectant\",\"Thermal Gun\",\"Disposable Seat Covers \",\"Extra legroom\",\"Mask\",\"Vaccinated Passengers and Crew\",\"No Blankets and No linen provided\"]", "via": "", "bus_layout": { "total_seats": 80, "coach_details": "1|SS-2|SS-|.GY-41|SS-42|SS,3|SS-4|SS-|.GY-43|SS-44|SS,5|SS-6|SS-|.GY-45|SS-46|SS,7|SS-8|SS-|.GY-47|SS-48|SS,9|SS-10|SS-|.GY-49|SS-50|SS,11|SS-12|SS-|.GY-51|SS-52|SS,13|SS-14|SS-|.GY-53|SS-54|SS,15|SS-16|SS-|.GY-55|SS-56|SS,17|SS-18|SS-|.GY-57|SS-58|SS,19|SS-20|SS-|.GY-59|SS-60|SS,21|SS-22|SS-|.GY-61|SS-62|SS,23|SS-24|SS-|.GY-63|SS-64|SS,25|SS-26|SS-|.GY-65|SS-66|SS,27|SS-28|SS-|.GY-67|SS-68|SS,29|SS-30|SS-|.GY-69|SS-70|SS,31|SS-32|SS-|.GY-71|SS-72|SS,33|SS-34|SS-|.GY-73|SS-74|SS,35|SS-36|SS-|.GY-75|SS-76|SS,37|SS-38|SS-|.GY-77|SS-78|SS,39|SS-40|SS-|.GY-79|SS-80|SS", "available": ",1|470.48,2|470.48,41|470.48,42|470.48,3|470.48,4|470.48,43|470.48,44|470.48,5|470.48,6|470.48,45|470.48,46|470.48,7|470.48,8|470.48,47|470.48,48|470.48,9|470.48,10|470.48,49|470.48,50|470.48,11|470.48,12|470.48,51|470.48,52|470.48,13|470.48,14|470.48,53|470.48,54|470.48,15|470.48,16|470.48,55|470.48,56|470.48,17|470.48,18|470.48,57|470.48,58|470.48,19|470.48,20|470.48,59|470.48,60|470.48,21|470.48,22|470.48,61|470.48,62|470.48,23|470.48,24|470.48,63|470.48,64|470.48,25|470.48,26|470.48,65|470.48,66|470.48,27|470.48,28|470.48,67|470.48,68|470.48,29|470.48,30|470.48,69|470.48,70|470.48,31|470.48,32|470.48,71|470.48,72|470.48,33|470.48,34|470.48,73|470.48,74|470.48,35|470.48,36|470.48,75|470.48,76|470.48,37|470.48,38|470.48,77|470.48,78|470.48,39|470.48,40|470.48,79|470.48,80|470.48", "available_gst": "1|23.52,2|23.52,41|23.52,42|23.52,3|23.52,4|23.52,43|23.52,44|23.52,5|23.52,6|23.52,45|23.52,46|23.52,7|23.52,8|23.52,47|23.52,48|23.52,9|23.52,10|23.52,49|23.52,50|23.52,11|23.52,12|23.52,51|23.52,52|23.52,13|23.52,14|23.52,53|23.52,54|23.52,15|23.52,16|23.52,55|23.52,56|23.52,17|23.52,18|23.52,57|23.52,58|23.52,19|23.52,20|23.52,59|23.52,60|23.52,21|23.52,22|23.52,61|23.52,62|23.52,23|23.52,24|23.52,63|23.52,64|23.52,25|23.52,26|23.52,65|23.52,66|23.52,27|23.52,28|23.52,67|23.52,68|23.52,29|23.52,30|23.52,69|23.52,70|23.52,31|23.52,32|23.52,71|23.52,72|23.52,33|23.52,34|23.52,73|23.52,74|23.52,35|23.52,36|23.52,75|23.52,76|23.52,37|23.52,38|23.52,77|23.52,78|23.52,39|23.52,40|23.52,79|23.52,80|23.52", "ladies_seats": "", "gents_seats": "", "ladies_booked_seats": "", "gents_booked_seats": "", "allow_gents_next_to_ladies": false, "allow_ladies_next_to_gents": false, "boarding_stages": "40560|13:00|AICTSL Campus Near Medical College, Near Suyash Hospital|Aictsl Campus Near Suyash Hospital|9993288888|Aictsl Campus : Near Medical Collage Near Suyyash Hospital|1|~327835|13:20|Plot No. 1212 & 1213, Hare Krishna Vihar,, Gram Nipaniya, Behind Best Price, Infront of Raja Bag Marriage Garden,|Behind Best Price, Infront Of Raja Bag Marriage Garden,|6232757414|Near Best Price|1|", "dropoff_stages": "73952|16:15|Bhopal-Indore Main Road Opp Mahindra Showroom, Near Lalghati, Bhopal, Madhya Pradesh|Near Lalghati Opp Mahindra Showroom|9993288888|Near Lalghati Opp. Mahindra Showroom |1|~282496|16:45|Shop No. 3, Shalimar Trade Centre, Hamidiya Road, Near Main Railway Station(Outside Platform No. 6)|Opp Bpcl Petrol Pump|7389921709|Bhopal Main Railway Station (Pickup Van/Bus)|1|~73950|16:45|Inter State Bus Terminal (ISBT), Near Rani Kamlapati Railway Station, Bhopal, Madhya Pradesh|Isbt Bhopal|9993288888|Inter State Bus Terminal (Isbt) (Pickup Van/Bus)|1|", "floor": "", "last_seats": "", "forced_seats": "", "fares_hash": { "SS": { "Adult": "470.48" } }, "branch_available": "1|494.0,2|494.0,41|494.0,42|494.0,3|494.0,4|494.0,43|494.0,44|494.0,5|494.0,6|494.0,45|494.0,46|494.0,7|494.0,8|494.0,47|494.0,48|494.0,9|494.0,10|494.0,49|494.0,50|494.0,11|494.0,12|494.0,51|494.0,52|494.0,13|494.0,14|494.0,53|494.0,54|494.0,15|494.0,16|494.0,55|494.0,56|494.0,17|494.0,18|494.0,57|494.0,58|494.0,19|494.0,20|494.0,59|494.0,60|494.0,21|494.0,22|494.0,61|494.0,62|494.0,23|494.0,24|494.0,63|494.0,64|494.0,25|494.0,26|494.0,65|494.0,66|494.0,27|494.0,28|494.0,67|494.0,68|494.0,29|494.0,30|494.0,69|494.0,70|494.0,31|494.0,32|494.0,71|494.0,72|494.0,33|494.0,34|494.0,73|494.0,74|494.0,35|494.0,36|494.0,75|494.0,76|494.0,37|494.0,38|494.0,77|494.0,78|494.0,39|494.0,40|494.0,79|494.0,80|494.0", "branch_available_gst": null }, "trip_id": "BITLA:2251:23", "city_seq_order": [ "512", "184" ], "cancellation_policy": "", "main_dep_time": "03/05/2022 13:00", "service_tax_percent": 5.0, "convenience_charge_percent": 0.0, "is_ac_bus": false, "api_type": 1, "allow_reschedule": false, "route_version": "458776166-21", "flexi_fare": null, "allow_ladies_to_book_double_seats": true, "is_seperate_service_tax_allowed": false, "is_inclusive_service_tax": true, "res_details": {}, "transaction_charges": "", "no_coach_layout": false, "is_package_fare_allowed": false, "cancellation_reference_type": "", "social_distancing_guaranteed": false, "offline_agent_quota": { "A3": "470.48", "A4": "470.48" } } } console.log(a.result.bus_layout.boarding_stages)
Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is easy and fast. The editor shows sample boilerplate code when you choose language as Javascript and start coding.
Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. Javascript is required to design the behaviour of the web pages.
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function(line){
console.log("Hello, " + line);
});
Keyword | Description | Scope |
---|---|---|
var | Var is used to declare variables(old way of declaring variables) | Function or global scope |
let | let is also used to declare variables(new way) | Global or block Scope |
const | const is used to declare const values. Once the value is assigned, it can not be modified | Global or block Scope |
let greetings = `Hello ${name}`
const msg = `
hello
world!
`
An array is a collection of items or values.
let arrayName = [value1, value2,..etc];
// or
let arrayName = new Array("value1","value2",..etc);
let mobiles = ["iPhone", "Samsung", "Pixel"];
// accessing an array
console.log(mobiles[0]);
// changing an array element
mobiles[3] = "Nokia";
Arrow Functions helps developers to write code in concise way, it’s introduced in ES6.
Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well.
() => expression
const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0)
.map(ele => ele ** 2);
console.log(squaresOfEvenNumbers);
let [firstName, lastName] = ['Foo', 'Bar']
let {firstName, lastName} = {
firstName: 'Foo',
lastName: 'Bar'
}
const {
title,
firstName,
lastName,
...rest
} = record;
//Object spread
const post = {
...options,
type: "new"
}
//array spread
const users = [
...adminUsers,
...normalUsers
]
function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
console.log(`Hello ${name}!`);
}
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar
IF is used to execute a block of code based on a condition.
if(condition){
// code
}
Else part is used to execute the block of code when the condition fails.
if(condition){
// code
} else {
// code
}
Switch is used to replace nested If-Else statements.
switch(condition){
case 'value1' :
//code
[break;]
case 'value2' :
//code
[break;]
.......
default :
//code
[break;]
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
ES6 introduced classes along with OOPS concepts in JS. Class is similar to a function which you can think like kind of template which will get called when ever you initialize class.
class className {
constructor() { ... } //Mandatory Class method
method1() { ... }
method2() { ... }
...
}
class Mobile {
constructor(model) {
this.name = model;
}
}
mbl = new Mobile("iPhone");