data = [ { "id": "0001", "href": "string", "correlationId": "string", "description": "string", "type": "MIGRACION", "productOrderClass": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "accountId": "string", "priority": 0, "requestedPriority": 0, "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "21324321" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" } } ] } ], "relatedObject": [ { "involvement": "Solicitud", "reference": "string", "href": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "additionalData": [ { "key": "Tipo de operacion comercial", "value": "BAJA ATIS" }, { "key": "Estado", "value": "accepted" }, { "key": "Fecha y hora", "value": "2021-06-06T15:09:19.000−05:00" }, { "key": "Fecha y hora de suspension", "value": "2021-06-10T15:09:19.000−05:00" }, { "key": "Fecha y hora de reconexion", "value": "2021-06-20T15:09:19.000−05:00" } ] } ], "channel": [ { "id": "string", "href": "string", "name": "string", "description": "string", "role": "string" } ], "requestedStartDate": "2021-07-06T06:52:16.000-05", "requestedCompletionDate": "2021-07-06T06:52:16.000-05", "orderDate": "2021-07-06T06:52:16.000-05", "lastModificationDate": "2021-07-06T06:52:16.000-05", "expectedCompletionDate": "2021-07-06T06:52:16.000-05", "completionDate": "2021-07-06T06:52:16.000-05", "note": [ { "date": "2021-07-06T06:52:16.398Z", "author": "string", "text": "string", "additionalData": [ { "key": "string", "value": "string" } ] } ], "product": { "id": "string", "href": "string", "name": "string", "publicId": "string", "description": "string", "productType": "mobile", "category": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "startDate": "2021-07-06T06:52:16.398Z", "terminationDate": "2021-07-06T06:52:16.398Z", "place": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string" } ], "productSpec": { "id": "string", "href": "string", "name": "string", "@referredType": "string" }, "characteristic": [ { "valueType": "String", "@type": "StringType" } ], "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "string" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" } } ] } ], "productRelationship": [ { "type": "bundle", "product": "string" } ], "additionalData": [ { "key": "string", "value": "string" } ] }, "status": "pending", "subStatus": "string", "statusReason": "string", "statusChangeDate": "2021-07-06T06:52:16.398Z", "source": "string", "orderItem": [ { "id": "string", "description": "string", "action": "add", "parent": "string", "productOffering": { "id": "string", "href": "string", "name": "string", "description": "string" }, "billingOffering": { "id": "string", "href": "string", "name": "string", "description": "string" }, "product": { "id": "string", "href": "string", "name": "string", "publicId": "string", "description": "string", "productType": "mobile", "category": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "startDate": "2021-07-06T06:52:16.398Z", "terminationDate": "2021-07-06T06:52:16.398Z", "place": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string" } ], "productSpec": { "id": "string", "href": "string", "name": "string", "@referredType": "string" }, "characteristic": [ { "valueType": "String", "@type": "StringType" } ], "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "string" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" } } ] } ], "productRelationship": [ { "type": "bundle", "product": "string" } ], "additionalData": [ { "key": "string", "value": "string" } ] }, "quantity": "string", "minQuantity": "string", "maxQuantity": "string", "orderItemPrice": [ { "id": "string", "name": "string", "description": "string", "isMandatory": true, "priceType": "recurring", "recurringChargePeriod": "daily", "unitOfMeasure": { "amount": 0, "maximum": 0, "minimum": 0, "units": "string" }, "price": { "amount": 0, "units": "string" }, "taxIncluded": true, "taxRate": 0, "taxType": "string", "prodPriceAlteration": [ { "name": "string", "description": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "priceCondition": "string", "priority": "string", "priceType": "string", "recurringChargePeriod": "daily", "applicationDuration": 0, "discountType": "amount", "unitOfMeasure": { "amount": 0, "maximum": 0, "minimum": 0, "units": "string" }, "price": { "amount": 0, "units": "string" }, "additionalData": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "string", "value": "string" } ] } ], "billingAccount": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string", "billingMethod": "prepaid" } ], "paymentMethod": { "id": "string", "href": "string", "@referredType": "cash", "name": "string", "description": "string" }, "status": "new", "statusReason": "string", "activationStatus": "new", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "isAutoRenew": true, "recurringPeriod": "string", "nrOfPeriods": 0, "relatedObject": [ { "involvement": "string", "reference": "string", "href": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "additionalData": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "string", "value": "string" } ] } ], "deploymentWorks": [ { "name": "string", "orderItems": [ "string" ], "costs": [ { "name": "string", "price": { "amount": 0, "units": "string" }, "type": "opex", "subject": "string" } ], "characteristics": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "Inscripcion", "value": "0000393383" }, { "key": "Fecha y hora de solicitud", "value": "2021-06-06T15:09:19.000−05:00" }, { "key": "Fecha y hora de suspension", "value": "2021-06-10T15:09:19.000−05:00" }, { "key": "Fecha y hora de reconexion", "value": "2021-06-20T15:09:19.000−05:00" } ] }, { "id": "002", "href": "string", "correlationId": "string", "description": "string", "type": "BAJA APC", "productOrderClass": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "accountId": "string", "priority": 0, "requestedPriority": 0, "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "21324321" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" } } ] } ], "relatedObject": [ { "involvement": "Solicitud", "reference": "string", "href": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "additionalData": [ { "key": "Tipo de operacion comercial", "value": "BAJA CMS" }, { "key": "Estado", "value": "accepted" }, { "key": "Fecha y hora", "value": "2021-06-07T15:09:19.000−05:00" }, { "key": "Fecha y hora de suspension", "value": "2021-06-10T15:09:19.000−05:00" }, { "key": "Fecha y hora de reconexion", "value": "2021-06-25T15:09:19.000−05:00" } ] } ], "channel": [ { "id": "string", "href": "string", "name": "string", "description": "string", "role": "string" } ], "requestedStartDate": "2021-07-06T06:52:16.000-05", "requestedCompletionDate": "2021-07-06T06:52:16.000-05", "orderDate": "2021-07-06T06:52:16.000-05", "lastModificationDate": "2021-07-06T06:52:16.000-05", "expectedCompletionDate": "2021-07-06T06:52:16.000-05", "completionDate": "2021-07-06T06:52:16.000-05", "note": [ { "date": "2021-07-06T06:52:16.398Z", "author": "string", "text": "string", "additionalData": [ { "key": "string", "value": "string" } ] } ], "product": { "id": "string", "href": "string", "name": "string", "publicId": "string", "description": "string", "productType": "mobile", "category": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "startDate": "2021-07-06T06:52:16.398Z", "terminationDate": "2021-07-06T06:52:16.398Z", "place": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string" } ], "productSpec": { "id": "string", "href": "string", "name": "string", "@referredType": "string" }, "characteristic": [ { "valueType": "String", "@type": "StringType" } ], "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "string" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" } } ] } ], "productRelationship": [ { "type": "bundle", "product": "string" } ], "additionalData": [ { "key": "string", "value": "string" } ] }, "status": "completed", "subStatus": "string", "statusReason": "string", "statusChangeDate": "2021-07-06T06:52:16.398Z", "source": "string", "orderItem": [ { "id": "string", "description": "string", "action": "add", "parent": "string", "productOffering": { "id": "string", "href": "string", "name": "string", "description": "string" }, "billingOffering": { "id": "string", "href": "string", "name": "string", "description": "string" }, "product": { "id": "string", "href": "string", "name": "string", "publicId": "string", "description": "string", "productType": "mobile", "category": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "startDate": "2021-07-06T06:52:16.398Z", "terminationDate": "2021-07-06T06:52:16.398Z", "place": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string" } ], "productSpec": { "id": "string", "href": "string", "name": "string", "@referredType": "string" }, "characteristic": [ { "valueType": "String", "@type": "StringType" } ], "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "string" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" } } ] } ], "productRelationship": [ { "type": "bundle", "product": "string" } ], "additionalData": [ { "key": "string", "value": "string" } ] }, "quantity": "string", "minQuantity": "string", "maxQuantity": "string", "orderItemPrice": [ { "id": "string", "name": "string", "description": "string", "isMandatory": true, "priceType": "recurring", "recurringChargePeriod": "daily", "unitOfMeasure": { "amount": 0, "maximum": 0, "minimum": 0, "units": "string" }, "price": { "amount": 0, "units": "string" }, "taxIncluded": true, "taxRate": 0, "taxType": "string", "prodPriceAlteration": [ { "name": "string", "description": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "priceCondition": "string", "priority": "string", "priceType": "string", "recurringChargePeriod": "daily", "applicationDuration": 0, "discountType": "amount", "unitOfMeasure": { "amount": 0, "maximum": 0, "minimum": 0, "units": "string" }, "price": { "amount": 0, "units": "string" }, "additionalData": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "string", "value": "string" } ] } ], "billingAccount": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string", "billingMethod": "prepaid" } ], "paymentMethod": { "id": "string", "href": "string", "@referredType": "cash", "name": "string", "description": "string" }, "status": "new", "statusReason": "string", "activationStatus": "new", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "isAutoRenew": true, "recurringPeriod": "string", "nrOfPeriods": 0, "relatedObject": [ { "involvement": "string", "reference": "string", "href": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "additionalData": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "string", "value": "string" } ] } ], "deploymentWorks": [ { "name": "string", "orderItems": [ "string" ], "costs": [ { "name": "string", "price": { "amount": 0, "units": "string" }, "type": "opex", "subject": "string" } ], "characteristics": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "Inscripcion", "value": "0000393384" }, { "key": "Fecha y hora de solicitud", "value": "2021-06-07T15:09:19.000−05:00" }, { "key": "Fecha y hora de suspension", "value": "2021-06-10T15:09:19.000−05:00" }, { "key": "Fecha y hora de reconexion", "value": "2021-06-25T15:09:19.000−05:00" } ] }, { "id": "003", "href": "string", "correlationId": "string", "description": "string", "type": "SUSPENSION APC", "productOrderClass": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "accountId": "string", "priority": 0, "requestedPriority": 0, "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "21324321" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" } } ] } ], "relatedObject": [ { "involvement": "Solicitud", "reference": "string", "href": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "additionalData": [ { "key": "Tipo de operacion comercial", "value": "" }, { "key": "Estado", "value": "accepted" }, { "key": "Fecha y hora", "value": "2021-06-08T15:09:19.000−05:00" }, { "key": "Fecha y hora de suspension", "value": "2021-06-10T15:09:19.000−05:00" }, { "key": "Fecha y hora de reconexion", "value": "2021-06-24T15:09:19.000−05:00" } ] } ], "channel": [ { "id": "string", "href": "string", "name": "string", "description": "string", "role": "string" } ], "requestedStartDate": "2021-07-06T06:52:16.000-05", "requestedCompletionDate": "2021-07-06T06:52:16.000-05", "orderDate": "2021-07-06T06:52:16.000-05", "lastModificationDate": "2021-07-06T06:52:16.000-05", "expectedCompletionDate": "2021-07-06T06:52:16.000-05", "completionDate": "2021-07-06T06:52:16.000-05", "note": [ { "date": "2021-07-06T06:52:16.398Z", "author": "string", "text": "string", "additionalData": [ { "key": "string", "value": "string" } ] } ], "product": { "id": "string", "href": "string", "name": "string", "publicId": "string", "description": "string", "productType": "mobile", "category": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "startDate": "2021-07-06T06:52:16.398Z", "terminationDate": "2021-07-06T06:52:16.398Z", "place": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string" } ], "productSpec": { "id": "string", "href": "string", "name": "string", "@referredType": "string" }, "characteristic": [ { "valueType": "String", "@type": "StringType" } ], "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "string" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" } } ] } ], "productRelationship": [ { "type": "bundle", "product": "string" } ], "additionalData": [ { "key": "string", "value": "string" } ] }, "status": "cancelled", "subStatus": "string", "statusReason": "string", "statusChangeDate": "2021-07-06T06:52:16.398Z", "source": "string", "orderItem": [ { "id": "string", "description": "string", "action": "add", "parent": "string", "productOffering": { "id": "string", "href": "string", "name": "string", "description": "string" }, "billingOffering": { "id": "string", "href": "string", "name": "string", "description": "string" }, "product": { "id": "string", "href": "string", "name": "string", "publicId": "string", "description": "string", "productType": "mobile", "category": [ { "id": "string", "href": "string", "name": "string", "subcategories": "string" } ], "startDate": "2021-07-06T06:52:16.398Z", "terminationDate": "2021-07-06T06:52:16.398Z", "place": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string" } ], "productSpec": { "id": "string", "href": "string", "name": "string", "@referredType": "string" }, "characteristic": [ { "valueType": "String", "@type": "StringType" } ], "relatedParty": [ { "id": "string", "href": "string", "name": "string", "role": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.398Z", "endDateTime": "2021-07-06T06:52:16.398Z" }, "@referredType": "string", "description": "string", "legalId": [ { "country": "string", "isPrimary": true, "nationalIdType": "string", "nationalId": "string" } ], "contactMedium": [ { "@type": "email", "name": "string", "preferred": true, "preferredContactTime": { "startTime": "string", "endTime": "string" }, "isActive": true, "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" } } ] } ], "productRelationship": [ { "type": "bundle", "product": "string" } ], "additionalData": [ { "key": "string", "value": "string" } ] }, "quantity": "string", "minQuantity": "string", "maxQuantity": "string", "orderItemPrice": [ { "id": "string", "name": "string", "description": "string", "isMandatory": true, "priceType": "recurring", "recurringChargePeriod": "daily", "unitOfMeasure": { "amount": 0, "maximum": 0, "minimum": 0, "units": "string" }, "price": { "amount": 0, "units": "string" }, "taxIncluded": true, "taxRate": 0, "taxType": "string", "prodPriceAlteration": [ { "name": "string", "description": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "priceCondition": "string", "priority": "string", "priceType": "string", "recurringChargePeriod": "daily", "applicationDuration": 0, "discountType": "amount", "unitOfMeasure": { "amount": 0, "maximum": 0, "minimum": 0, "units": "string" }, "price": { "amount": 0, "units": "string" }, "additionalData": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "string", "value": "string" } ] } ], "billingAccount": [ { "id": "string", "href": "string", "name": "string", "@referredType": "string", "billingMethod": "prepaid" } ], "paymentMethod": { "id": "string", "href": "string", "@referredType": "cash", "name": "string", "description": "string" }, "status": "new", "statusReason": "string", "activationStatus": "new", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "isAutoRenew": true, "recurringPeriod": "string", "nrOfPeriods": 0, "relatedObject": [ { "involvement": "string", "reference": "string", "href": "string", "validFor": { "startDateTime": "2021-07-06T06:52:16.399Z", "endDateTime": "2021-07-06T06:52:16.399Z" }, "additionalData": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "string", "value": "string" } ] } ], "deploymentWorks": [ { "name": "string", "orderItems": [ "string" ], "costs": [ { "name": "string", "price": { "amount": 0, "units": "string" }, "type": "opex", "subject": "string" } ], "characteristics": [ { "key": "string", "value": "string" } ] } ], "additionalData": [ { "key": "Inscripcion", "value": "0000393388" }, { "key": "Fecha y hora de solicitud", "value": "2021-06-08T15:09:19.000−05:00" }, { "key": "Fecha y hora de suspension", "value": "2021-06-10T15:09:19.000−05:00" }, { "key": "Fecha y hora de reconexion", "value": "2021-06-24T15:09:19.000−05:00" } ] } ] var dataOrderSolcitud = { dateRequest: "", dateRegister: "", dateRecox: "" } var dateRequest = ''; var dateRegister = ''; var dateRecox = ''; var dataResponse = data.map(itemResponse => { const involvement = itemResponse.relatedObject[0].involvement; console.log("involvement: ", involvement) const additionalData = itemResponse.relatedObject[0].additionalData; console.log("additionalData: ", additionalData) //const itemValue = additionalData.filter(item => item.key == "Fecha y hora").map( item => item.value); //console.log("itemValue: ", itemValue.toString()) getItemValue(involvement, additionalData) function getItemValue (inv, arrayData) { if (inv === 'Solicitud') { arrayData.map(itemData => { switch(itemData.key) { case "Fecha y hora": dateRequest = itemData.value case "Fecha y hora de reconexion": dateRegister = itemData.value case "Fecha y hora de reconexion": dateRecox = itemData.value } }) } }; console.log("dateRequest: ", dateRequest) console.log("dateRegister: ", dateRegister) console.log("dateRecox: ", dateRecox) });
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");