Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

63
Views
Why do i get the this error if i try this js code?

Why do i get the error

TypeError: Cannot set properties of undefined (setting '6')
at Object.<anonymous> (/home/runner/*******/index.js:5:8)
at Module._compile (node:internal/modules/cjs/loader:1101:14)

in my code that I tried to swap varibles' content using the destructuring assignment i got that error and im shure that there is no misstaque and I'm not that great of a dev so please help me my code "formated":

let [a,b] = [8,6];
console.log("a:" ,a ,"b:", b)
[a, b] = [b, a]
console.log("a:" ,a ,"b:", b)

the result "try it your self please":

a: 8 b: 6
TypeError: Cannot set properties of undefined (setting '6')
    at Object.<anonymous> (/home/runner/seeing-what-is-js/index.js:5:8)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

Missing semicolon after console.log call

automatic semicolon insertion (JS) read it up for more informations.

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs