Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
How do I destructure strings in JS using a special character?

I want day,month and year values from the value in an object.

{myDate : '12/31/2020'}

I want to do something like this:

d,m,y = mydate('/')

so that d= 12, m=31 , y = 2020 and they are separated using the '/' character

Is there a way to do something like this in JS?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Split the string and destructure the resulting array:

const myDate = {myDate : '12/31/2020'}
const [d,m,y] = myDate.myDate.split('/')
console.log(d,m,y)

about 4 years ago · Juan Pablo Isaza Report

0

const [d,m,y] = '12/31/2020'.split("/")

console.log(d,m,y)

about 4 years ago · Juan Pablo Isaza Report

0

Use

mydate = "12/30/2021";
var arr = mydate.split("/");
//arr[0]=12
//arr[1] is day
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!