What is the typescript/javascript equivalent of java string.getBytes()?

I have a java line of code that I want to convert to typescript.

NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, "text/vcard".getBytes(), new byte[] {}, messagebytes);

NdefRecord is a function that takes the following parameters: (tnf:number,type:string|number[],id:string|number[],payload:string|number[])

I tried several approaches to writing getBytes alternatives in typescript:

var vcard= `BEGIN:VCARDnVERSION:2.1nN:;${firstName}nORG: ${org}nEMAIL:${email}nEND:VCARD`;
var payload = this.nfc.stringToBytes(vcard)
var encoder = new TextEncoder();
var array = Array.from(encoder.encode("text/vcard"))

1:

record = this.ndef.record(tnf, array, [], payload); 

2:

record = this.ndef.record(tnf, encoder.encode("text/vcard").toString(), [], payload);

3:

record = this.ndef.record(tnf, this.nfc.stringToBytes("text/vcard"), [], payload); 

The first and third approaches yield a JSON error, whereas the second returns the contents of the vcard as a string.
Is there any way to get the bytes of the record type “text/vcard”?