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

251
Views
¿Cómo funciona la asignación de variables en javascript?
class Node{ constructor(val) { this.val = val; this.next = null; } } class SinglyLingkedList{ constructor() { this.head = null; this.tail = null; this.length = 0; } push(val){ var newNode = new Node(val) if (this.head == null) { this.head = newNode; this.tail = this.head; } else{ this.tail.next = newNode; this.tail = newNode; } this.length++; return this } reverse(){ var node = this.head; this.head.next = null; this.tail = this.head; return node; } } var list = new SinglyLingkedList() list.push("1") list.push("2") list.push("3") list.reverse()

Soy nuevo en la programación. Estoy bastante confundido con mi asignación de variables en el método inverso, especialmente en

 var node = this.head; this.head.next = null; this.tail = this.head; return node;

¿Por qué el nodo de retorno se ve afectado por this.head.next null? no es como lo que esperaba su regreso

 Node : {val: '1', next: null}

no

 Node : {val: '1', next: Node}

queria saber por que paso

about 4 years ago · Juan Pablo Isaza
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!