How to create an object from a file .js in QML?

What am I doing wrong?
There is a js file, a primitive constructor function.
in qml I want by allocating memory to create an object from this js file and fill.
function device( ip,name,port,community,oid_count)

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import "device_obj.js" as Device
ApplicationWindow {
 visible: true
 width: 640
 height: 480
 color: "#a3a3a3"
 title: qsTr("Hello World")

Button {
 id: button_ok
 x: 468
 y: 423
 text: qsTr("Button_OK")

 var ip="123";
 var name="123";
 var port="123";
 var community="123";
 var oid_count="123"
 var device= new Device(ip,name,port,community,oid_count);



Error on string memory allocation using NEW. TypeError: Type error
August 23rd 19 at 10:31
1 answer
August 23rd 19 at 10:33
There is a special, street js.

Create a file Device.qml, inside it write:
Item {
 property string ip
 property string port
 // There may be a constructor function

Then either create
Device {
 id: device

and in the handler of the button fill in its fields.

Either create the object dynamically,

Find more questions by tags QMLQt