0

How would one go about creating a javascript object (not literal) in LWC? i understand the standard syntax of something like

function bar(dog, cat) {
  this.dog = dog;
  this.cat = car;
  this.getdetails = function() {
  return this.dog + this.cat}
  }

how could this be executed in the lwc javascript file? i've tried something like this:

Bike() {
        function blah(tet,sarah) {
            this.tet = tet;
            this.sarah = sarah
        }
      }

However its scoping the tet and sarah variables to the overall class, not the function blah. Am i missing something obvious here? (could be the case)

1 Answer 1

-1

Sample code, creating a class outside of the lightning elements class is the easiest way

import { LightningElement, api, track, wire} from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import findFiles from '@salesforce/apex/fileFoldersClass.findFiles';

class blah {
    constructor(tett,ugh) {
        this.tett = tett;
        this.ugh=ugh
    }
}

export default class OpenFileSample extends LightningElement() {
triggerObject creation() {

        const reeee = new blah('fire','pants')

    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .