'how to add an artboard to a document in Adobe Illustrator?

I wrote a script in JavaScript for Adobe Illustrator CC 2017. In this script I am trying to add artboard to the document in function, but it isn't working.

Here code:

function addArtboard() {
    var doc = app.documents.add(null,1000,1000);
    doc = app.activeDocument;
    var artboards = doc.artboards;
     artboards.add([0 , 0, 1000, 1000]);
}
 
addArtboard();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source