let x = { SC: { code: "SC", teleCode: "U+1F1F8 U+1F1E8", name: "Seychelles", emoji: "๐ธ๐จ" }, SD: { code: "SD", teleCode: "U+1F1F8 U+1F1E9", name: "Sudan", emoji: "๐ธ๐ฉ" }, SE: { code: "SE", teleCode: "U+1F1F8 U+1F1EA", name: "Sweden", emoji: "๐ธ๐ช" }, SG: { code: "SG", teleCode: "U+1F1F8 U+1F1EC", name: "Singapore", emoji: "๐ธ๐ฌ" }, SH: { code: "SH", teleCode: "U+1F1F8 U+1F1ED", name: "St. Helena", emoji: "๐ธ๐ญ" }, SI: { code: "SI", teleCode: "U+1F1F8 U+1F1EE", name: "Slovenia", emoji: "๐ธ๐ฎ" }, SJ: { code: "SJ", teleCode: "U+1F1F8 U+1F1EF", name: "Svalbard & Jan Mayen", emoji: "๐ธ๐ฏ" }, SK: { code: "SK", teleCode: "U+1F1F8 U+1F1F0", name: "Slovakia", emoji: "๐ธ๐ฐ" }, SL: { code: "SL", teleCode: "U+1F1F8 U+1F1F1", name: "Sierra Leone", emoji: "๐ธ๐ฑ" }, SM: { code: "SM", teleCode: "U+1F1F8 U+1F1F2", name: "San Marino", emoji: "๐ธ๐ฒ" }, SN: { code: "SN", teleCode: "U+1F1F8 U+1F1F3", name: "Senegal", emoji: "๐ธ๐ณ" }, SO: { code: "SO", teleCode: "U+1F1F8 U+1F1F4", name: "Somalia", emoji: "๐ธ๐ด" }, SR: { code: "SR", teleCode: "U+1F1F8 U+1F1F7", name: "Suriname", emoji: "๐ธ๐ท" }, SS: { code: "SS", teleCode: "U+1F1F8 U+1F1F8", name: "South Sudan", emoji: "๐ธ๐ธ" }, ST: { code: "ST", teleCode: "U+1F1F8 U+1F1F9", name: "Sรฃo Tomรฉ & Prรญncipe", emoji: "๐ธ๐น" }, SV: { code: "SV", teleCode: "U+1F1F8 U+1F1FB", name: "El Salvador", emoji: "๐ธ๐ป" }, SX: { code: "SX", teleCode: "U+1F1F8 U+1F1FD", name: "Sint Maarten", emoji: "๐ธ๐ฝ" }, SY: { code: "SY", teleCode: "U+1F1F8 U+1F1FE", name: "Syria", emoji: "๐ธ๐พ" }, SZ: { code: "SZ", teleCode: "U+1F1F8 U+1F1FF", name: "Swaziland", emoji: "๐ธ๐ฟ" }, TA: { code: "TA", teleCode: "U+1F1F9 U+1F1E6", name: "Tristan da Cunha", emoji: "๐น๐ฆ" }, TC: { code: "TC", teleCode: "U+1F1F9 U+1F1E8", name: "Turks & Caicos Islands", emoji: "๐น๐จ" }, TD: { code: "TD", teleCode: "U+1F1F9 U+1F1E9", name: "Chad", emoji: "๐น๐ฉ" }, TF: { code: "TF", teleCode: "U+1F1F9 U+1F1EB", name: "French Southern Territories", emoji: "๐น๐ซ" }, TG: { code: "TG", teleCode: "U+1F1F9 U+1F1EC", name: "Togo", emoji: "๐น๐ฌ" }, TH: { code: "TH", teleCode: "U+1F1F9 U+1F1ED", name: "Thailand", emoji: "๐น๐ญ" }, TJ: { code: "TJ", teleCode: "U+1F1F9 U+1F1EF", name: "Tajikistan", emoji: "๐น๐ฏ" }, TK: { code: "TK", teleCode: "U+1F1F9 U+1F1F0", name: "Tokelau", emoji: "๐น๐ฐ" }, TL: { code: "TL", teleCode: "U+1F1F9 U+1F1F1", name: "Timor-Leste", emoji: "๐น๐ฑ" }, TM: { code: "TM", teleCode: "U+1F1F9 U+1F1F2", name: "Turkmenistan", emoji: "๐น๐ฒ" }, TN: { code: "TN", teleCode: "U+1F1F9 U+1F1F3", name: "Tunisia", emoji: "๐น๐ณ" }, TO: { code: "TO", teleCode: "U+1F1F9 U+1F1F4", name: "Tonga", emoji: "๐น๐ด" }, TR: { code: "TR", teleCode: "U+1F1F9 U+1F1F7", name: "Turkey", emoji: "๐น๐ท" }, TT: { code: "TT", teleCode: "U+1F1F9 U+1F1F9", name: "Trinidad & Tobago", emoji: "๐น๐น" }, TV: { code: "TV", teleCode: "U+1F1F9 U+1F1FB", name: "Tuvalu", emoji: "๐น๐ป" }, TW: { code: "TW", teleCode: "U+1F1F9 U+1F1FC", name: "Taiwan", emoji: "๐น๐ผ" }, TZ: { code: "TZ", teleCode: "U+1F1F9 U+1F1FF", name: "Tanzania", emoji: "๐น๐ฟ" }, UA: { code: "UA", teleCode: "U+1F1FA U+1F1E6", name: "Ukraine", emoji: "๐บ๐ฆ" }, UG: { code: "UG", teleCode: "U+1F1FA U+1F1EC", name: "Uganda", emoji: "๐บ๐ฌ" }, UM: { code: "UM", teleCode: "U+1F1FA U+1F1F2", name: "U.S. Outlying Islands", emoji: "๐บ๐ฒ" }, UN: { code: "UN", teleCode: "U+1F1FA U+1F1F3", name: "United Nations", emoji: "๐บ๐ณ" }, US: { code: "US", teleCode: "U+1F1FA U+1F1F8", name: "United States", emoji: "๐บ๐ธ" }, UY: { code: "UY", teleCode: "U+1F1FA U+1F1FE", name: "Uruguay", emoji: "๐บ๐พ" }, UZ: { code: "UZ", teleCode: "U+1F1FA U+1F1FF", name: "Uzbekistan", emoji: "๐บ๐ฟ" }, VA: { code: "VA", teleCode: "U+1F1FB U+1F1E6", name: "Vatican City", emoji: "๐ป๐ฆ" }, VC: { code: "VC", teleCode: "U+1F1FB U+1F1E8", name: "St. Vincent & Grenadines", emoji: "๐ป๐จ" }, VE: { code: "VE", teleCode: "U+1F1FB U+1F1EA", name: "Venezuela", emoji: "๐ป๐ช" }, VG: { code: "VG", teleCode: "U+1F1FB U+1F1EC", name: "British Virgin Islands", emoji: "๐ป๐ฌ" }, VI: { code: "VI", teleCode: "U+1F1FB U+1F1EE", name: "U.S. Virgin Islands", emoji: "๐ป๐ฎ" }, VN: { code: "VN", teleCode: "U+1F1FB U+1F1F3", name: "Vietnam", emoji: "๐ป๐ณ" }, VU: { code: "VU", teleCode: "U+1F1FB U+1F1FA", name: "Vanuatu", emoji: "๐ป๐บ" }, WF: { code: "WF", teleCode: "U+1F1FC U+1F1EB", name: "Wallis & Futuna", emoji: "๐ผ๐ซ" }, WS: { code: "WS", teleCode: "U+1F1FC U+1F1F8", name: "Samoa", emoji: "๐ผ๐ธ" }, XK: { code: "XK", teleCode: "U+1F1FD U+1F1F0", name: "Kosovo", emoji: "๐ฝ๐ฐ" }, YE: { code: "YE", teleCode: "U+1F1FE U+1F1EA", name: "Yemen", emoji: "๐พ๐ช" }, YT: { code: "YT", teleCode: "U+1F1FE U+1F1F9", name: "Mayotte", emoji: "๐พ๐น" }, ZA: { code: "ZA", teleCode: "U+1F1FF U+1F1E6", name: "South Africa", emoji: "๐ฟ๐ฆ" }, ZM: { code: "ZM", teleCode: "U+1F1FF U+1F1F2", name: "Zambia", emoji: "๐ฟ๐ฒ" }, ZW: { code: "ZW", teleCode: "U+1F1FF U+1F1FC", name: "Zimbabwe", emoji: "๐ฟ๐ผ" } }; let y = [] Object.entries(x).forEach(item => y.push(item[1])); console.log(y);
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");