Como sacar parámetros de una url a un objeto con javascript

Url de ejemplo https://compbcn.es/?param1=hola&param2=mundo const params = location.search.slice(1).split('&'); Donde nos sale: (2) ["param1=hola", "param2=mundo"];

Y luego pasar estos datos a un objeto util para trabajar en futuro:

const resultado = params.reduce( (prev,current) => {
const [name,value] = current.split('=');
prev[name] = value;
return prev;
} ,{} );
Nos sale n objeto asi:
{param:"hola",param2="mundo"}

Así vemos que sacar parámetros de una url no es tan complicado con «reduce».

Aplicando función de un array (reduce), nos pasamos parámetros (prev, (el resultado de función (reduce), current (elemento corriente) y
un objecto vació {} .

Y entonces ya se puede sacar valor de nuevo objecto así: resultado.param. Saldra «hola» y resultado.param saldra «mundo».

Espero que este ejemplo sea util.

0 comentarios sobre “Como sacar parámetros de una url a un objeto con javascript

  1. lybofqjw dice: El comentario está esperando ser moderado.

    Special Prices

    Order Medications Online No Prior Prescription – Click Here To Continue

    Ms. Fial worked to burnish the reputation of mangoes, avocados, radishes and celery, among other produce. Olympic swimmer Ian Thorpe has revealed the touching way he is staying in contact with his 90-year-old grandmother during the coronavirus pandemic.
    After 20 seasons and six championships with the New England Patriots, Brady is joining his second N.F.L. team. President Trump said he would look at pardoning Joe Exotic, the star of the Netflix series ‘Tiger King’ who is currently serving 22 years in prison for a murder-for-hire plot. Therapist Beth Thompson of The Woman’s Trust centre in West London, revealed the challenges of buy cod-efferalgan safely helping victims of domestic abuse during lockdown. The head of the World Health Organization gave a strident defense of his agency’s handling of the coronavirus pandemic on Wednesday, in response to U.S. President Donald Trump’s criticism and suggestion that order eleuphrat charlotte Washington could review its funding for the agency. There’s a new way to get up close and personal with animals in Africa. It doesnt involve bouncing around in the back of a Land Rover its a cycling safari. Neil Simpson investigates… The largest, brightest supermoon of 2020 rose in the night sky on Tuesday over hushed cities, stilled factories and countries in lockdown. Diageo’s 2020 forecast saw organic sales up 2%, EBIT up 0-2% Suspends 3-year 4.5 bln pound buyback programme The Dawson’s Creek star said last month of his wife’s pregnancy ‘We are in the very, very home stretch. Everybody tells us that the first baby’s late so we’re probably 10ish days away.’ The nation’s Communist Party is on a mission to show its 1.4billion citizens – and the rest of the world – that it’s taking action to make up for the damage caused by the coronavirus outbreak, she said. England stars at all levels are set to battle it out in a FIFA 20 tournament to raise awareness for the National Emergencies Trust amid the coronavirus pandemic. A study found up to 18 per cent of all people could be left hand dominant, but the figure could be as low as 9.34 per cent, according to research from the University of St Andrews. The move for a card that includes a highly anticipated fight involving Tony Ferguson is an end run around state regulators and nationwide public health guidelines. The estimated death toll from the coronavirus pandemic in the US is now expected to reach 60,000 in the next purchase now lotriderm visa australia four months after new projections scaled back the number of fatalities by 26 percent. Kimberley Duthie shot to fame as a teenager in 2010 and 2011 when she leaked the crude images of St Kilda players and became embroiled in a sex scandal with Ricky Nixon. Herbert von Karajan, who died in 1989, shifted 200 million albums – an astonishing figure for a classical musician. The coronavirus outbreak is closing down some businesses, leaving workers unsure how they can support themselves during the crisis. This is how unemployment works. Suddenly, the White House loves Bernie Sanders. For a biseptol mail order online shopping platform tennis championship, the players socially distanced by wearing gloves and not touching the same tennis balls. There was a trophy, but the winner didnt take it home. But this was live sports, and ESPN streamed it.
    Moscow’s famed Bolshoi Theater has begun streaming some of its most notable past performances online after being forced to shut its doors to the public as a result of tough new restrictions aimed at curbing the spread of the coronavirus.
    A professional soccer team from Wuhan, China, went to Spain for preseason training. And got stuck. For six weeks. On Thursday, they let @tariqpanja in to talk about how they are holding up. Coronavirus deaths in the United States now total 14,831, an increase of 1,887 new deaths on Wednesday as the projected peak of April 12 grows closer. Although quarantines are considered a measure of last resort, police powers give states, counties order generic bicalutamide california and even cities broad authority to make residents stay home.
    P.E. Nation founder Pip Edwards has denied romance rumours with Michael Clarke following the cricketer’s split from wife Kyly.
    Indian children are using more education apps, as schools close in its nationwide lockdown. Players in the farm system have long been vulnerable because they lack a union, and the coronavirus pandemic has only complicated things for them. A nonprofit is aiming to change things. The 29-year-old SAG Award nolpaza without prescription cost winner said she’s much more like her onscreen mother Claire (Julie Bowen) than Haley Alexandra Cearns, a photographer from Perth, curated Perfect Imperfection, which collates heart-warming snaps of pooches and felines living with disabilities.
    Rita Ora has been doing her best to stay fit in lockdown, sharing a video of her home workout efforts on Wednesday. The company’s share price closed at a peak of 14.35 on Wednesday, its highest ever, which left the business exceeding a 9.9 billion value. The shares settled back to 13.96 on Friday evening. The C.D.C. outlined how essential employees can go back to work even if they have been exposed. Scientists warn that the virus might not fade in warm weather. The low-cost carriers shares have a choppy morning as it reports a solid jump in annual profits and a 35% hike in its dividend. Casualty departments in England recorded just 1.53million attendances last month, down 430,000 – 22 per cent – on February, according to data released by NHS England. In advance of the launch of streaming service HBO Max, HBO will seek to ease the act of social distancing by making 500 hours of programming available free for a limited time, under the heading StayHomeBoxOffice. C Pam Zhangs debut, How Much of These Hills Is Gold, is one of several new or forthcoming buy american stieva-a 100mg books by Asian-American writers set in a period that historically hasnt recognized them. Every 15 minutes or so, a hearse pulls up in front of the crematorium lumigan cheap fast in Madrid. A priest greets family members, delivers blessings, and douses the casket with holy water. There’s no eulogy, and there’s hardly even time for a goodbye. Royal Dutch Shell’s greenhouse gas emissions declined in 2019 to their lowest in four years, according to data provided by the energy company. Industry body UK Steel has urged ministers to make more money available in addition to aid promised last prescription for betamethasone online week for firms struggling in the wake of the coronavirus outbreak. The victory over Dominic Thiem in five sets gave Djokovic his 17th Grand Slam singles title, and allowed him to reclaim the No. 1 ranking. The Vermont senator39;s presidential bid got off to a strong start but took a turn south in South Carolina and on Super Tuesday. His campaign never recovered This brothy, flavorful dish may be just what youre looking for after all those baking projects and beans. Foreign players in the Korean Baseball Organization who went home during the peak of South Koreas outbreak are self-isolating as the league aims to resume exhibitions later this month. Zoom, the videoconferencing app, has become a target for harassment buy dicaris reddit and abuse coordinated in private off-platform chats. As scientists and politicians struggle for a response to the coronavirus, many people are turning to faith. But some practices raise public health concerns. When the disgraced health entrepreneur Elizabeth Holmes was indicted on fraud charges for her lab-testing company Theranos last year, much of the media discussion rested not on her alleged corporate recklessness and staggering abuses of trust, but on her sartorial choices black jackets, order now cheapest trental europe black slacks, and — most importantly — black turtlenecks.
    European companies are scrapping dividends to maintain cash and comply with regulations in response to the financial havoc caused by the spread of the new coronavirus. The SP 500 is up 23 percent from its low last month. Opportunistic buyers are seeking bargains, while short-sellers are paradoxically helping amplify the rally.
    Gary Lineker decided it was time to transform his lounge into a makeshift TV studio on Wednesday amid the COVID-19 lockdown. Gig workers seemingly eligible for unemployment pay because of the pandemic have met reddit buy isotretinoin roadblocks to filing. Some fault Labor Department rules. Amy Schumer is being sued for copyright infringement,according to a new lawsuit filed in New York on Tuesday and obtained exclusively by DailyMail.com. A touching handwritten letter from Princess Diana to Sergeant George Plumb with the scrawled signatures from young Princes William and Harry has emerged for sale for 16,000.
    With the tennis calendar in disarray amid the coronavirus pandemic, Canadian star buy zomig using paypal account Milos Raonic hopes the rescheduling of tournaments won’t be detrimental to player welfare. Democratic Governor Tony Evers moved on Monday to postpone Wisconsin’s primary election from Tuesday until June 9, citing health risks from the coronavirus pandemic, but Republicans said they would challenge the order in the state Supreme Court. Colette Luke has more. Our first reader-generated itinerary a weekend of traveling you can do from ranexa 500mg fast delivery home. Carnival and the other big companies have no revenue and face questions over whether customers will return once the threat of the coronavirus passes. U.S. singer Pink said on Friday she had tested positive for COVID-19, the respiratory disease caused by the new coronavirus, two weeks ago and has since recovered. In the late 1980s, Tyson has revealed how he tried to bribe a zookeeper to letting him climb into the gorilla enclosure and fight one of their Silverbacks. UK online car marketplace Auto Trader said on Wednesday it is seeking to raise about 186 million pounds ($230 million) in an equity placement from institutional investors in a bid to shore up cash during the coronavirus crisis. JANET STREET-PORTER Whether we like it or not, Gordon Ramsay has the right to take his family to their beach house in Cornwall, because he wants (understandably) to keep them safe. An array of workout videos from over the decades that you can enjoy even from (maybe especially from) the comfort of your couch. Sticking to three of four key recommendations – such as keeping a low BMI and drinking in moderation – can add nearly a decade of disease-free years to your life, according to new research. A trial of researchers from the US and Europe are beginning a trial in which coronavirus patients will inhale nitric oxide through a CPAP machine for 20 to 30 minutes a day, twice daily, for two weeks.
    Gregg Wallace has admitted that his wife Anna – and their 11-month-old son Sid – have spurred on his recent fitness transformation. Doctors at the elite King Faisal Specialist Hospital in Riyadh that treats members of the royal family are preparing 500 more beds for an expected influx of patients. U.S. intelligence picked up information on a spreading outbreak in China’s Wuhan province in November, and warned Pentagon and White House officials about it, according to a new report. Cheney Orr knew that Alzheimer’s would take his father away. Photography purchase guidelines helped him get to know the man. Coronavirus, Saudi Arabia, Bernie Sanders Here39;s what you need to know.
    Read CNN’s Fast Facts on Haiti and learn more about the poorest country in the Western Hemisphere.
    It wasnt the Democratic establishment that defeated him. It was the ceiling on his support. A man linked to the Barossa Valley coronavirus cluster has died in hospital. After a long panto season stage-weary Jonathan Wilkes swapped Stoke-on-Trent for the Caribbean sunshine. During two weeks with PO cruises he sampled the best the islands generic progesterone for cheap have to offer.
    Tallulah Willis is a buzzed beauty after her famous purchase online shop father Bruce Willis treated her to a dramatic haircut on Tuesday night during their self-isolation with mom Demi Moore. It wasnt the Democratic establishment that defeated him. It purchase daflon 200mg tablets was the ceiling on his support.
    The 78-year-old travelled from Melbourne to Sydney on Wednesday stopping target pharmacy arava price briefly at a servo to buy a phone charger and newspapers. A car maker in southern India has designed a car shaped like the microscopic image of the coronavirus to inform people about the dangers of the fast-spreading virus and appeal to them to stay indoors. Super League Triathlon has made a foray into the world of esports and enlisted leading athletes such as double Olympic champion Alistair Brownlee and reigning Super League champion Vincent Luis to take part in the online Zwift Classics series.
    The Spanish epidemic has become a painful example of the tendency of one government after another to ignore the experiences of countries where the virus has already struck. Noel Gallagher, 52, has asked his local council to build 6.6ft high gates and install seven CCTV cameras to shield the grounds of his seven-bedroom country mansion in East Hampshire. Researchers have found that Sandy’s Integrated Kinetic Energy index, or IKE, which quantifies the power of a hurricane based on how far out tropical-storm force winds extend from the center, ranked second only to Hurricane Isabel in 2003. Four years ago Golden Globes host Ricky Gervais turned his sharp tongue on voters of the awards show, ridiculing them for nominating the poorly reviewed Johnny Depp-Angelina Jolie action thriller «The Tourist.» Meghan Markle and Prince Harry fans primperan canada low cost who type in http://www.archewellfoundation.com are unwittingly diverted to the music video of the American rapper’s 2005 hit Gold Digger, featuring Jamie Foxx. The stand-up Eugene Mirman gave many stars their start, yet he didnt follow them to L.A. Instead, he stayed on the purchase diprophos tablets East Coast to be near family through the death of his wife. Before it hits what eventually turns out to be its totally delicious stride, there are moments when this new production of Jane Austen’s Emma looks as if it’s simply going to be too much. WARNING – EXPLICIT LANGUAGE A Manchester City fan entered the press box cheap cytoxan from overseas at Wembley at the end of the FA Cup final and launched a foul-mouthed rant towards journalists. Except for treating Covid-19, many hospitals seem to be eerily quiet.
    A real restaurant critic’s wife writes a novel, «The Restaurant Critic’s Wife,» with just enough truth in the fiction. MATTHEW SMITH AT WEMBLEY Danny Rowe scored the winner as Fylde beat Leyton Orient 1-0 in the FA Trophy final. Rowe found the net with an excellent free-kick on the hour mark.
    Make a meal out of just about any root vegetable by rounding it out with a bit more protein and luscious creamy texture. Scottish First Minister Nicola Sturgeon confirmed the UK faces weeks more of draconian curbs, saying there was not yet enough evidence the ‘social distancing’ measures had the outbreak under control.
    The number of scenarios that we have to plan for is staggering. A California retail developer claims the state’s coronavirus lockdown was an act of God that prevented it from completing a $4.2 million property acquisition, asking a court to prevent owner Exxon Mobil Corp from selling to any other buyers. The clinical psychologist Lisa Damour discusses the specific challenges of raising teenagers during the pandemic, and Dwight Garner asks Pamela Paul about putting together the Book Review. CNN Open Court traveled to Rhode Island to see how a gifted team of silversmiths craft the US Open trophy. The 40-year-old acrobatic pop star and her thre-year-old son Jameson Moon are now free from the coronavirus
    Hoping to build on buzz from last year, the N.H.L. All-Star skills competition will add a U.S.A. vs. Canada three-on-three game.
    Ana-Rose Thorpe, 29, from Manchester, who is waiting for a liver transplant, says the issue is a ‘matter of life and death’ for her because her health is deteriorating at home.
    June 15 – A community in East Java, Indonesia, is turning methane from the local garbage dump into gas for more than 400 homes. Local authorities have set up a system where methane produced by rotting waste is extracted and pumped to villages nearby, turning greenhouse gas emissions into useful energy. Tara Cleary reports. Matthew Bellonis departure takes the staff by surprise. He clashed with his bosses, who run a prominent film and TV studio, over coverage of the entertainment industry. For the most part, Kate Fall regards her role as a memoirist as an extension of her job as gatekeeper to present the polished face of the Cameron administration to the world It is said thatGriezmann upset many of his prospective team-mates last summer buy pure dermovate when he revealed his decision to snub a move to Barcelona in a documentary called’The Decision’. These days, teachers often face classrooms filled with yawning students who stayed up late snapping selfies or playing online games. Guy Robertson, who runs the Mount Gnomon Farm in Penguin, Tasmania, received a phone call from a French ‘official’ warning him to stop using the name ‘champagne’ and call it ‘rhubarb sparkling’. Beijing has tried to protect jobs and spur lending, but it may have to do more to get its huge, damaged and incredibly complex genox buy 5mg economy going again. I would encourage anyone interested in understanding the Great Depression or mid-19th century place to buy doxazosin Britain to turn to Steinbeck or Dickens. Though most municipal offices are closed across the country, some cities are still issuing licenses to nonresident couples who plan to marry within city or state limits. A small passenger plane skidded off the runway and smashed into a parked helicopter at the only airport in Nepal’s Everest region on Sunday. Out of the mouths of babes; children share their interpretations of the virus and quarantine experiences. WAG Rebecca Judd moved into her family’s $7.3 canadian healthcare meldonium sales million Melbourne mansion in October following months of extensive renovations.
    While this campaign is coming to an end, our movement is not, Mr. Sanders said in a video address order now apetamin-p online australia on Wednesday.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Booking.com